Category: json

JSON Tutorial:

JSON Tutorial:  Hi readers today we come up with the new concept of JSON which will be explained in detail in this tutorial. Here in this JSON tutorials, we will guide you from What is JSON to the simple example of JSON. So this tutorial is useful even for beginners and professionals to get the deep knowledge of JSON.

In Brief:

JSON stands for JavaScript Object Notation and it is based on the subset of JavaScript Programming Language.

JSON is language independent i.e can be used with any programming language.

JSON is easy and human readable and store data in Key-Value Pair.

Topic-Wise List of JSON Tutorial :

What is JSON?

Difference between JSON and XML.

JSON Examples

JSON Objects

JSON Array

JSON Comments


NEXT Topic         What is JSON ?      

JSON Tutorial:  JSON Object 

JSON Object Using PHP:  Hi readers this JSON tutorial is all about JSON Object Here in this tutorial we will explain the details about JSON object which includes what is JSON Object Using PHP Syntax, JSON object with Strings, JSON object with Numbers, JSON object with boolean, and JSON nested objects with examples.

JSON Object Using PHP Syntax: 

{"key1": value1 , "key2": value2 , ...}
{"ID" : 1001, "name" : "Sudhansu" , "age": 24 , "married" : true }

JSON Object starts with the opening curly braces {  and ends with the ending curly braces  }.

JSON Object is stored in the Key/Value Pair format enclosed with curly braces {}.

Each Key and values are separated by a colon (:)

Keys must be any Strings enclosed with double quotation (” “) whereas values can be any valid JSON datatype (string, number, boolean, object, array or null)

Each key/value pair is separated by a comma(,).

In the above example:

KEY:    ID, name, age, married

VALUES: 1001, “Sudhansu”, 24, true.

Note:  Here some values are numeric, String and Boolean datatype.

JSON Object with Strings:

Let us understand the JSON object with Strings by the following example:

"ID" : "A001",
"Name": "Awdesh Rai",
"Age": "26"

Here you can see all the values are of String Datatype (enclosed with double quotes).

JSON Object Using PHP with Numbers:

Number datatype in JSON is similar to Integer or int or numeric in any other languages.

JSON number datatype can be any (0-9) digits, fractions (0.33, 0.98, etc.) and exponents (e, e+, e-, E, E+, E-) .

JSON also support floating-point format i.e., Numbers with double precision.

Simple example:

"ID" : 1001,
"height": 67.5,
"width": 26.35,
"exp"  : 6.617e+1

Here you can see all the values are of Number Datatype (digits, fraction or exponent form).

JSON Object Using PHP with Boolean:

Boolean datatype in JSON is similar to the Boolean datatype in any other languages.

JSON Boolean data type can be either “true” or “false”.

Simple example:

"value1" : true,
"value2" : false

Here you can see Boolean datatype have values either true or false.

JSON Object with another Object: (Nested Object)

JSON Object can be nested as well. Here Nesting means one or more object can be used within another object.

Let us understand the Nested JSON objects by the following example:

{ //start of object1

 "studentId": "SJ011MS",
 "name": "Deepak Singh",
 "gender": "Male",
 "age": "27",
 { //start of object2
 "city": "varanasi",
 "state": "Uttar Pradesh",
 "pincode": "221001"
 //end of object2
 "course": "B.S.c",
 "section": "B"
//end of object1

Here in the above example, you can see that the address object is used within another object.

Let us understand the Nested Object with another example:

"student1" :{
"ID" : "A001",
"Name": "Awdesh Rai",
"Age": "26"

"student2" :{ 
"ID" : "A002",
"Name": "Subham Mishra",
"Age": "33"

Here we can see that we have used two JSON object i.e, student1 information and student2 information which is nested within another JSON Object.


 Previous Topic                                                                     Next Topic

 JSON and XML                                                                  JSON Array

What Is JSON?

What is JSON?: This tutorial begins with the Introduction of JSON in detail. Some of the features of JSON is also explained in this JSON tutorial.


Here we have started JSON Tutorial with simple Question What is JSON ?

JSON is lightweight data interchange format that means it is basically used to exchange data over servers.

JSON is open standard and originated from JavaScript.

JSON is a JavaScript Object Notation i.e it is a subset of JavaScript Programming Language.

JSON is Language Independent i.e, can be used with any Programming languages like C, C++, JAVA, PHP, Perl, etc.

JSON is a simple text stored in a Key-Value Pair which is in human readable format (easy to understand)

JSON supports data structures such as array and objects.


Features of JSON:

(1)  Simplicity           :    JSON is very simple to use. We can easily read and write JSON data in a Key and Value Pair format.

(2)  Self-Describing  :    JSON itself  describe the content 

(3)  Openness           :   JSON is open standard 

(3)  Extensibilty        :  JSON is extensible.

(4)  Interoperability  :  JSON supports all type of browsers and even all type of Programming Languages.


JSON Data is stored in Key/Value Pair.

Key:                     A Key in JSON is a field name in string format always enclosed in quotation marks(“”).

Value:                  Value is something like the values of key(or any Field) which can be Sting, Integer, Boolean, Object or an Array.

Key-Value Pair:    It follows a specific Syntax to store Value i.e. Key followed by a colon(:) and then followed by the Value.

                           Key-Value Pairs are Comma Separated(,) .For Example:

     { "StudentId":   "STU0012",
       "name":        "Vikash Agrawall"


I hope you would like this topic on What is JSON

              Next                         JSON and XML

JSON Comments

JSON Comments


JSON Comments

JSON Comments:  Hi readers in this JSON tutorial we have explained the JSON Comments. As we know Comments are one of the most important concepts in any programming language. Comments one not only beneficial for beginners to understand the programming code but also it helps the professionals to keep records of what logic is used to the code so he/she even can starts coding after a long time from where he/she left out.

In Short, Comments are added to make the code easier and more understandable for human beings which are generally ignored by Compilers, Interpreter, and Web Browsers.

JSON Comment: 

Comments are strictly not supported by JSON.

But However we can give the comments in JSON by some tricky method to fulfill our basic needs.
Here is the simple example through which we can understand adding comments in JSON:
 "studentName": "Vikash Lal",
 "age" : 24,
 "Comments" : "Good Student"

Here in the above example, we can consider the “Comments” attribute as Comments in JSON.

Previous Topic:   JSON Array

I hope you would like this JSON Comment in PHP!