JS JSON

JS Tutorial

JS Version

JS Objects

JS Function

JS Classes

JS Async

JS HTML DOM

JS Browser BOM

JS Web API

JS AJAX

JS JSON

JS vs JQUERY

JS Graphics

JavaScript JSON

JSON is a syntax for storing and transporting data.

JSON is used when data is sent from a server to a web page.

What is JSON?

  • JSON stands for JavaScript Object Notation.
  • JSON is a lightweight data interchange format.
  • JSON is language independent *.
  • JSON is “self-describing” and easy to understand.

* The JSON syntax is derived from JavaScript object notation syntax, but the JSON format is text only.

JSON Example

This JSON syntax specifies an employees object: an array of 3 employee records (objects):

{

“employees”:[

  {“firstName”:”John”, “lastName”:”Doe”},

  {“firstName”:”Anna”, “lastName”:”Smith”},

  {“firstName”:”Peter”, “lastName”:”Jones”}

]

}

The JSON Format Evaluates to JavaScript Objects

The JSON format is similar to the code for creating JavaScript objects.

Due to this similarity, a JavaScript program can be used to convert JSON data into native JavaScript objects.

JSON Syntax Rules

  • Data is in name/value pairs.
  • Data is separated by commas.
  • Curly braces hold objects.
  • Square brackets hold arrays.