---
title: "JSON Syntax"  
description: "In this blog, I’m explaining the syntax rules for JSON.  JSON is the JavaScript Object Notation that is used for data store and interchanging the data"  
author: "Anchal Kesharwani"  
published: 2014-09-22  
updated: 2014-09-22  
canonical: https://www.mindstick.com/blog/695/json-syntax  
category: "json"  
tags: ["json"]  
reading_time: 3 minutes  

---

# JSON Syntax

In this blog, I’m explaining the syntax rules for JSON.\

JSON is the [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) Object Notation that is used for data store and interchanging the data.

##### There are following syntax to create JSON:

[JSON Data](https://www.mindstick.com/forum/782/how-to-send-request-amp-amp-response-from-json-data-using-asp-dot-net) Syntax

JSON data syntax for name and values. In the JSON how to give data name and the value? JSON Data gives data name as double code and value also but not necessary to every case:

##### Syntax

## “data_name”:”data_value”

##### Example

## “name”:”Amit Singh”

JSON values does not allow all values to double that means it’s define how value is [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) or [Boolean](https://www.mindstick.com/forum/160332/how-does-the-boolean-function-work), etc.

There are following JSON value can accept:

· A number may be integer or float that is not in the double codes.

· A string use the double code.

· A Boolean can accept the [true or false](https://www.mindstick.com/forum/160329/how-can-you-convert-a-value-to-a-boolean-true-or-false-in-javascript) without double codes.

· An array define under the square brackets ‘[]’.

· null is not to give any value.

##### Create JSON Objects

To create the JSON [objects](https://www.mindstick.com/forum/145447/what-are-objects) use the [curly braces](https://answers.mindstick.com/qa/31876/when-we-use-curly-braces-in-the-string-format-its-not-working-in-c-sharp) ’{}’. It accept the multi values for the object. Here, an example of [student](https://www.mindstick.com/articles/157138/student-loan-default-wage-garnishment-and-student-loan) that contain the name, age, and [employee](https://www.mindstick.com/articles/85431/remote-employee-training-tips-tricks) or not and phone number.

##### Example

```
                {“name”:”Ajay Mishra”,”age”:21, employer:false, ”phone”:”121 123567”}
```

##### Try this example to understand it:

```
 <!DOCTYPE html><html><body> <h2>Create JSON Object  in JavaScript</h2><p  id="student"></p>  <script>var student =  '{"name":"Ajay  Mishra","age":21,"address":"Allahabad","phone":"555  1234567","email":"ajay@mail.com"}'; var obj = JSON.parse(student); document.getElementById("student").innerHTML  ="<b>Name  </b>"+obj.name + "<br>" +"<b>Age  </b>"+obj.age +"<br>" +"<b>Address  </b>"+obj.address + "<br>" +"<b>Phone  </b>"+obj.phone+"<br>"+"<b>E-mail  </b>"+obj.email;</script> </body> </html>
```

The [JSON Object](https://www.mindstick.com/forum/699/how-to-parse-into-json-object-using-json-parse-in-node-js) is given output as student

**![JSON Syntax](https://www.mindstick.com/blogs/582ae7cd-9d34-435a-a2bd-de794112b022/images/04a8618a-bf05-465e-ba5b-c5d3cfc38b71.png)**

In this example name is the string, age is integer, and employer is Boolean that all types defined values.

##### Create JSON Arrays

Arrays works normally other programming languages. Arrays created in the square brackets.

##### Example

```
  “students”:[                    {“name”:”Ajay Mishra”,”age”:21, employer:false, ”phone”:”121 123567”},                     {“name”:”Satish Kumar”,”age”:21, employer:true, ”phone”:”121 123568”},                    {“name”:”Amit Singh”,”age”:21, employer:false, ”phone”:”121 123569”}];
```

In the above example, the ‘students’ is an array object that contain the three JSON objects that contain all student information as name, age employer and the phone number.

##### JSON uses the JavaScript Syntax

JSON use the JavaScript syntax. The JSON that not need to any extra software it use only the JavaScript.

With the JavaScript you can create an array objects as like this:

##### Example

```
    var students = [                  {“name”:”Ajay Mishra”,”age”:21, employer:false, ”phone”:”121 123567”},                {“name”:”Satish Kumar”,”age”:21, employer:true, ”phone”:”121 123568”},           {“name”:”Amit Singh”,”age”:21, employer:false, ”phone”:”121 123569”}];
```

This example as similar to JSON syntax but little difference.

##### Create JSON Files

JSON file create with the extension of .json that contain mime type with the “application/json”.

---

Original Source: https://www.mindstick.com/blog/695/json-syntax

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
