Archive

Archive for the ‘JSON’ Category

Json javascript ajax php – Example

October 28, 2009 4 comments

This post will help you to understand complete flow of Json. This will also help you to learn how to use use json with ajax and php.

Here is the simple example for form validation(server side) through AJAX and JSON.
Read more…

Categories: AJAX, Javascript, JSON, PHP

Json Syntax – Examples

October 28, 2009 Leave a comment

Declaration
All JSON objects are declared with a pair of curly braces. You can assign them to a variable like you would any other data structure.

      var myObj = {}

Read more…

Categories: Javascript, JSON, PHP

JSON – Introduction

October 28, 2009 Leave a comment

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

JSON is built on two structures:
– Objects / Associative array.
– Array.

An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
Ex: {blog:web4us,topic:json}

An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).
Ex: [web4us,json]

How JSON will be useful with AJAX

As we know Ajax is a web development technology that makes the server responses faster by enabling the client-side scripts to retrieve only the required data from the server without retrieving a complete web page on each request, which will minimize the data transferred from the server.

These requests usually retrieve xml formatted response, the xml responses are then parsed in the JavaScript code to render the results. Which complicate the JavaScript code

The idea of JSON (JavaScript Object Notation) is to make the response a specific data structure that can be easily parsed by the JavaScript code.

Advantages
1- lightweight data-interchange format
2- Easy for humans to read and write
3- Easy for machines to parse and generate
4- JSON can be parsed trivially using the eval() procedure in JavaScript

5- JSON Supports: ActionScript, C, C#, ColdFusion, E, Java, JavaScript, ML, Objective CAML, Perl, PHP, Python, Rebol, Ruby, and Lua.

Categories: Javascript, JSON, PHP