WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JSON Tutorial



JSON

JSON: J ava S cript O bject N otation (JavaScript object notation)

JSON is the syntax for storing and exchanging text information. Similar to XML.

JSON is smaller, faster, and easier to parse than XML.


JSON Example

{"employees":[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]}

The sites object is an array of 3 site records (objects).

XML Example

<employees>
    <employee>
        <firstName>John</firstName> <lastName>Doe</lastName>
    </employee>
    <employee>
        <firstName>Anna</firstName> <lastName>Smith</lastName>
    </employee>
    <employee>
        <firstName>Peter</firstName> <lastName>Jones</lastName>
    </employee>
</employees>

What is JSON?

  • JSON stands for JavaScript Object Notation ( J ava S cript O bject N otation) < /li>
  • JSON is a lightweight text data interchange format
  • JSON is language independent: JSON uses Javascript syntax to describe data objects, but JSON is still language and platform independent. The JSON parser and JSON library support many different programming languages. Currently, many dynamic (PHP, JSP, .NET) programming languages support JSON.
  • JSON is self-describing and easier to understand

JSON-convert to JavaScript object

The JSON text format is syntactically the same as the code for creating JavaScript objects.

Because of this similarity, no parser is required, and JavaScript programs can use the built-in eval () function to generate native JavaScript objects from JSON data.