What is JSON?
JSON stands for JavaScript Object Notation.
JSON is a lightweight format for storing and transporting data. The JSON is similar to JavaScript Objects syntax wise but JSON is text-only. It is used primarily to transmit data between a server and web application, as an alternative to XML.
The JSON format is syntactically identical to the code for creating JavaScript objects and JavaScript can easily convert JSON code into native JavaScript objects with its inbuilt string methods.
Since JSON format is text only, it can easily be sent tot and form a server, and used as a data format by programming language.
JSON Code example
The JSON format is identical to JavaScript Objects. JSON data consists of key/value
pairs similar to JavaScript object properties. The key and values are
written in double quotes separated by a colon. JSON objects are written
inside curly braces. Just like JavaScript, objects can contain multiple
name/value pairs.
JSON is built in two structures:
- A collection of name/values pairs. In various languages, this is realized as an object, or list.
- An ordered list of values. This is realized as an array, or vector.
The JSON values must be one of the following data type:
- a string
- a number
- an object
- an array
- a boolean
- null
Values of JSON cannot be one of the following data types:
- a function
- a date
- undefined
Common JSON Example
Convert Object to JSON String
Converting the JavaScript to JSON String with JSON.stringify().
Convert JSON to JavaScript Object
Parsing the JSON Data with JSON.parse(), the data becomes JavaScript Object.
0 Response to "What is JSON?"
Post a Comment