DEV Community

Dat One Dev
Dat One Dev

Posted on

What is JSON?

Introduction

Hey fellas
Ever wondered what is JSON ?

I mean, it’s everywhere.
You hear about it in APIs.
It shows up in Android projects.
Some JavaScript dev (definitely not me, promise 😅) probably talked about the term mid-convo and just kept like everyone knew what it meant.

Well today, we’re going to understand that what is JSON actually , why it’s so popular, and where it's used.

Let’s get started!

What is JSON?

JSON stands for JavaScript Object Notation.

It’s a lightweight format used to store and exchange data.
Think of it like this:

A simple format that computers and humans can both read easily.

{
  "name": "Selfish Dev",
  "gender": "male",
  "isGameDev": true,
  "tools": ["Godot", "Aseprite"]
}
Enter fullscreen mode Exit fullscreen mode

That right there is a JSON object.

  • It uses key-value pairs (like name: "Selfish Dev")
  • Keys are always in quotes
  • Values can be strings, numbers, booleans, arrays, or even other JSON objects

And that's what JSON is.

Common Uses of JSON:

  • APIs(REST, GraphQL responses)

  • Configuration files (e.g., package.json in Node.js)

  • Storing structured data (NoSQL databases like MongoDB)

  • Data exchange between frontend & backend

How to Use JSON in JavaScript:

  • Parse JSON string → Object:
const jsonString = '{"name": "Selfish", "gender": "male"}';
const obj = JSON.parse(jsonString);
console.log(obj.name); // Output: "Selfish"
Enter fullscreen mode Exit fullscreen mode
  • Parse Object → JSON string :
const user = '{"name": "Selfish", "gender": "male"}';
const jsonString = JSON.stringify(user);
console.log(jsonString); // Output: '{"name": "Selfish", "gender": "male"}'
Enter fullscreen mode Exit fullscreen mode

JSON is a fundamental tool in modern web development due to its simplicity and versatility.

Outro

Make sure to give a heart on this post , drop down your thoughts , checkout out my youtube channel (Its more awesome) Selfish Dev.

Till then stay curios and stay selfish

Top comments (0)