Categories: Json

Syntax of JSON

Share

Basically Syntax of JSON is the subset of the JavaScript syntax.

It has following notation:

  • Data is represented in name/value pairs.
  • The name/value pairs are separated by , (comma).
  • Curly braces hold objects.
  • Square brackets hold arrays.

Below is a example of Syntax of JSON:

{"students":[
 {"Name":"Tim", "Age":"25"},
 {"Name":"John", "Age":"30"},
 {"Name":"Jane", "Age":"45"}
 ]}

So,
students[0].Name + “:” + Name[0].Age;

will be Tim:25

The following datatypes are supported by JSON:
Number, String, Boolean, Array, Object, Whitespace, null

Read Also: Json JSON with Ajax

JSON reads data from a web server, and display in a web page.

var text = ‘{“students”:[
{“Name”:”Tim”, “Age”:”25″},
{“Name”:”John”, “Age”:”30″},
{“Name”:”Jane”, “Age”:”45″}
]}’;

Object From String:
JSON.parse(text) can be used to convert a JSON string into a JavaScript object:
var obj = JSON.parse(text);

Using eval():
You can use eval() function to convert a JSON string into a JavaScript object:
var obj = eval (“(” + text + “)”);

JSON is not a document format and this is not a markup language. Even, this is not a general serialization format in that it does not have a direct representation for cyclical structures, although it can support a meta representation that does.

JSON is not extensible and it does not need to be. It can represent any non-recurrent data structure as it is. JSON is a flexible as new fields can be added to existing structures without obsoleting existing programs.
In this sense, XML is also not extensible. This is possible to add new tags and attributes, but this is not possible to extend XML to add expressive syntax for arrays and objects and numbers and booleans.

View Comments

  • This is the right web site for everyone who wishes to find out about this topic. You know a whole lot its almost hard
    to argue with you (not that I actually would want to? HaHa). You certainly put a fresh spin on a topic that has been written about for years.
    Great stuff, just excellent!

Published by
Jacob Frazier

Recent Posts

The Sharp-Looking Guy: 5 Essential Tips for Men to Become Sharp

We've gotten so used to seeing men streetwear joggers, ripped jeans, and sleeveless shirts. Hair…

1 day ago

How to Use Your Wedding Jewellery In Unique Ways At Festivals

When it comes to festivals, the options for wedding jewellery are endless. You can go…

1 day ago

5 Tips On Window Cleaning

Whether it concerns your home or an office building, the state of a property’s windows…

1 day ago

Sustainable Business Practices: A Win-Win Strategy

You know that running an environmentally sustainable business is the right thing to do. But…

1 day ago

Unlock Growth – Guide to Online Financing and Business Loans for Entrepreneurs

If you are in a financial crisis , or need to start a new business…

1 day ago

7 Key Factors That Help In Selecting the Best Fleet Management Software

To realize the strategic advantage from the fleet management system (FMS) and differentiate the business…

1 day ago