Learn JSON in 5 Minutes

 


Learn JSON in 5 Minutes:

JSON Stands for JavaScript Object Notation, it's light-weight format for storing and transporting knowledge through API from server to an internet page. it's conjointly 'self describing' and simple to grasp.

JSON Data types :

1. JSON Strings



{ "name":"expoashish"}


Here "name" is a key and "expoashish" is its value.


2. JSON Numbers

 
{ "Age":18}


Here "Age" is a key and 18 is value, which is a number type.


3. JSON Objects


{ "friends":[
        {
            "name":"Rohan",
            "age":20,
            "email":"rohan@gmail.com"
        },
        {
            "name":"Ashish",
            "age":18,
            "dob":"23/12/1996",
            "isFriend":true
        }
    ] }


here "friends" could be a key and its values area unit in array knowledge sort which contains 2 objects. His first friend is Rohan and second friend is Ashish.


4. JSON Arrays


{"hobbies":["Learn to code", "Painting", "Blogging", "Writing"]}


Here "hobbies" could be a key and it's multiple values in array

format separated by commas.


5. JSON Booleans


"isFriend":true


Here "isFriend" could be a key and its price in Boolean format that

can be either true or false.


6. JSON Null


{"middle_name":null}


"middle_name" could be a key and its price in null format. if one thing has no price than we are able to assign null to its price for instance some folks haven't any name therein case we are able to assign null price. 

A typical use of JSON is to exchange knowledge to/from an internet server. once receiving knowledge from an internet server, the information is usually in string format.

Parse the information with JSON.parse() and the information become javaScript object.

_Example _ ( knowledge returning from an internet server )


'{ "name":"Ashish", "city":"New Delhi"}'


The information is in string format currently we'd like to convert it into javaScript Object by using JSON.parse().



var obj = JSON.parse('{ "name":"Ajay", "city":"New Delhi"}');


Now You can use

Thank you

Previous Post
Next Post

Hello, I am Ashish Yadav. Youtuber | Blogger | Programmer | Digital Marketer. Working on 3 Youtube Channel: 1. Expo Ashish 2. Expo Facts 3. Best Code Creator

Related Posts

Do Subscribe My Youtube Channel