JSON Syntax Rules
JSON syntax is a subset of the JavaScript object notation syntax:
  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces hold objects
  • Square brackets hold arrays

JSON values can be:
  • A number (integer or floating point)
  • A string (in double quotes)
  • A Boolean (true or false)
  • An array (in square brackets)
  • An object (in curly braces)
  • Null

JSON Objects
  • JSON objects are written inside curly braces.
  • Just like JavaScript, JSON objects can contain multiple name/values pairs:
  • {"firstName":"Amit", "lastName":"Gupta"}

JSON Arrays
JSON arrays are written inside square brackets.

Just like JavaScript, a JSON array can contain multiple objects:


    {"firstName":"Amit", "lastName":"Gupta"},
    {"firstName":"Ashish", "lastName":"Awasthi"},

Number{ "myNum": 123.456 }
A series of numbers; decimals ok; double-precision floating-point format.

String{ "myString": "abcdef" }
A series of characters (letters, numbers, or symbols); double-quoted UTF-8 with backslash escaping.

Boolean{ "myBool": true }
True or false.

Array{ "myArray": [ "a", "b", "c", "d" ] }
Sequence of comma-separated values (any data type); enclosed in square brackets.

Object{ "myObject": { "id": 7 } };
Unordered collection of comma-separated key/value pairs; enclosed in curly braces; properties (keys) are distinct strings.

Null{ "myNull": null }
Variable with null (empty) value.


Popular posts from this blog

Conversion from Clob To String in java and Vice versa

Portable Java 8/ JDK8 setup without admin rights

Multi Threading , Producer consumer problem in Java