Knowledge Base
MilesWeb / Web Hosting FAQ

What Is JSON? Everything That You Need To Know About It

Approx. read time : 3 min

JavaScript Object Notation (JSON) is an open-standard file format, used to exchange information that is readable to humans. This file contains only text and uses the extension .json.
It is a lightweight format used for storing and transporting data between a server and web application, as an alternative to the XML. In simple words, JSON gives human-readable collection of data that we are able to access in a logical manner.

Usage of JSON –

Most of the developers use JSON so as to work with AJAX (Asynchronous JavaScript and XML). Both these formats work well together in order to provide you the asynchronous loading of stored data that simply means, the website can update its information without refreshing the page.
This format is often used to serialize and transmit structured data over a network connection.
It also allows users to request data from a different domain with the help of a method called as JSON by using (<script>)  tags. Without this, you cannot transfer data across-domains.

Structures of JSON –

JSON is built on two structures :

(i) A collection of name/value pairs. In most of the languages, this is known as an object, record, dictionary, struct, hash table, keyed list or an associate array.

(ii) An ordered list of values. In most of the languages, this is known as an array, vector, list, or sequence.

Related: Why Should You Shift Your Java Applications To MilesWeb PaaS Containers?

JSON syntax rules :

(i) Data is always in key/value pair.

(ii) Data is always separated by commas.

(iii) Curly braces hold objects.

(iv) Square brackets hold arrays.

Example : “gender” : “male”

Here:          key (name) = gender and

value = male

Different types of Values are :

(i) Array – Array of values

e.g :

 "students":[

{"firstName": "Jack", "lastName": "Timothy"},

{"firstName": "Sam", "lastName": "Green"}

]

Or

{

   "firstName" : "Jack",

   "lastName" : "Timothy",

   "gender" : "male",

 "hobby" : ["football", "painting", "swimming"]

}

Note: Difference here is that, the key Hobby has several values (football, painting, swimming) mentioned in a square brackets, which represents an array.

(ii) Boolean – True or False

 {"sale" : "false"}

(iii) Number – An integer

{"age" : "25"}

(iv) Object – It is an associate array of key/value pairs 

    {

    "id" : "48",

    "language" : "Java",

    "price" : 500,

}

(v) String – Several plain characters that usually form a word

 "firstName" : "Jack"

If you want to store JSON data, there are two way to accomplish it. First is objects and the next one is arrays. In this section, we will discuss more about them below.

Using Objects

Curly brackets begin and end a JSON object. Comma-separated lines contain key/value pairs called properties. Each key and value are separated by a colon.

Strings are required for keys, but numbers, objects, arrays, booleans, and nulls are allowed for values.

There is a difference between JSON objects and objects in the JSON data type. Arrays of key-value pairs serve as a storage method, while associative arrays represent key-value pairs.

Now for your convenience, let’s take the example of three keys, Name, roll number and class with values like Thomas, 24 and 7 A.

{

“Name”:”Thomas”,

“rollnumber”:”24″,

“Class”:”7A”

}

Using Arrays

The use of arrays is another method of storing data. Each line is separated by a comma, with the values enclosed in square brackets. It is possible to have different types of values in JSON arrays.

As opposed to arrays as values, JSON arrays are collections of elements that are typically all the same type.

Let’s have an overview as an example:

{

“Name”:”Thomas”,

” rollnumber “:”24”,

“Class”:”7A”,

“subjects”: [

“english”,

“science”,

“maths”

]

}

What Differs Both?

The fourth key/value pair differentiates this method from the previous one. The key is subjects, and there are several values in the square brackets (english, science, maths).

When paired with JSONP, arrays can be used to overcome cross-domain issues. Furthermore, they support loops, allowing users to run repeated commands to look up data faster.

Conclusion –

From the above examples, you might have understood that JSON is a useful tool that can be used to interchange data in a manner that can easily be understood by humans.

It can load information asynchronously so that, your website becomes more responsive and can handle the data stream more easily. Also, JSON is easy and lightweight than XML.

With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna