Good Morning to all,
Today we discuss JSON related topic like introduction, advantage, syntax etc.
The light-weight text-data interchange format is a JavaScript Object Notation or short form is JSON.
It is used to store the information in an organized manner.
It helps to transmit data between web application and server. It is designed for human-readable data interchange.
Overview of JSON
- JSON stands for JavaScript Object Notation
- JSON is not a programming language
- The JSON has extended from JavaScript Scripting language.
- The light weight text data interchange is JSON
- the file name extrnsion is .json
Advantage of JSON
- It is alternative of XML.
- It is a lightweight data-interchange format.
- It is is language independent, That means, you can you JSON with any language.
- It is easy to use and understand.
- JSON is easy to read and write
JSON Syntax
All syntax of JSON is same like JavaScript syntax. JSON syntax is derived from JavaScript object notation syntax
- In JSON data is write in name/value pairs.
- Square brackets are used for store arrays.
- Every data in JSON is separated using commas.
- Curly braces are used for store objects.
JSON data – Name and a Value
In JSON data is write in name/value pairs, every name is written in double quotes ” ” . And each data is separated using commas.
"employeefirstName":"Pritty"
JSON Objects
JSON objects are written inside the curly braces like { }. Same like JavaScript JSON objects can contain multiple name/values pairs.
{"employeefirstName":"Pritty", "employeelastName":"Times"}
JSON Arrays
JSON arrays are written inside square brackets [ ]. Same like JavaScript, a JSON array can contain multiple objects.
"employees":[
{"employeefirstName":"Pritty", "employeelastName":"Times"},
{"employeefirstName":"Princy", "employeelastName":"Varghese"},
{"employeefirstName":"Prince", "employeelastName":"Thomas"}
]
JSON Datatype
TYPE | DESCRIPTION |
---|---|
Number | double- precision floating-point format in JavaScript |
String | double-quoted Unicode with backslash escaping |
Boolean | true or false |
Array | an ordered sequence of values |
Value | it can be a string, a number, true or false, null etc |
Object | an un-ordered collection of key:value pairs |
Whitespace | It can be used between any pair of tokens |
null | empty |
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.