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 Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (1)

Collapse
 
Sloan, the sloth mascot
Comment deleted

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more