-->
What is JSON?

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.

The JSON names require double quotes. JavaScript variables names don’t require.

JSON is built in two structures:
  1. A collection of name/values pairs. In various languages, this is realized as an object, or list.
  2. 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.

Thanks for Reading this blog, Please share this blog if you have liked it.





0 Response to "What is JSON?"

Post a Comment

Ads on article

Advertise in articles 1

advertising articles 2

Advertise under the article