DEV Community

Cover image for Things to know as a Beginner in JSON.
Coder Pink
Coder Pink

Posted on • Edited on

2 1 1 1 1

Things to know as a Beginner in JSON.

Things to remember...

  1. JSON stands for JavaScript Object Notation.

  2. JSON is very lightweight as compared to XML.

  3. It is text format for storing and retrieving data.

  4. It is human readable and easy to understand.

  5. It is very good to use JSON rather than XML.

  6. With JSON, can easily integrate with JavaScript.

  7. The file type for JSON files is ".json"


example of JSON...

'{"name":"Tae", "age":26, "bike":null, "isGood" : true}'
Enter fullscreen mode Exit fullscreen mode

in the above example, we can see that JSON is like an object that has key-value pairs. you have to enclose the JSON object with backticks(``).

It can take values as numbers, strings, null, Boolean, array and object.
You can also store an array in array, object in arrays as long as it is readable.

``



newJson = '{"name":"Tae", "age":26, "bike":null, "isGood" : true}'

//'{"name":"Tae", "age":26, "bike":null, "isGood" : true}'

parsedJson = JSON.parse(newJson)

// {name: 'Tae', age: 26, bike: null, isGood: true}

parsedJson['age']

//26

parsedJson["isGood"]

//true


Enter fullscreen mode Exit fullscreen mode


``

Store json object in new variable named newJson.

parse the jSON object so that you will get the JavaScript object and can access JavaScript object.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (1)

Collapse
 
Sloan, the sloth mascot
Comment deleted

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay