JSON
JSON is an acronym for JavaScript Object Notation.
Lightweight and text-based, designed explicitly for human-readable data interchange.
It supports data structures like objects and arrays.
Data is represented in key-value pairs.
Curly braces hold objects.
Colon is followed after each name.
Comma is used to separate key-value pairs.
Square brackets are used to hold arrays, where each value is comma-separated.
Why do we use JSON?
Less Verbose.
Faster.
Readable.
Structured Data.
JSON Data Types
String - always written in double-quotes. Ex: "student".
Number.
Boolean.
Null.
JSON Objects
{"name" : "Jack", "employeeid" : 001, "present" : false}
Enclosed in curly brackets.
Key has to be a string.
Values have to be a valid JSON data type such as string, number, and object, Boolean or
null.
Key and values are separated by a colon.
A comma separates each key/value pair.
JSON Arrays
Enclosed in square brackets [ ].
An array value can be a string, number, object, array, Boolean or null.
Out
put:
JSON Vs XML
JSON doesn't support comments. It is not a standard.