API Fundamentals Course
API Fundamentals
/
Beginner

JSON Format

Definition

JavaScript Object Notation. A lightweight, text-based, language-independent data interchange format that is easy for humans to read and write, and easy for machines to parse and generate.

Explain Like I'm New

Before JSON, servers sent data using XML, which was horribly ugly, bloated, and hard to read. JSON looks exactly like a standard JavaScript object (with a few strict rules). It is now the undisputed universal language of Web APIs.

Real World Example

A Python backend querying a Postgres database, formatting the result as a JSON string, sending it over the internet, and a React frontend parsing that JSON string back into a usable object.

Common Use Cases

  • API payloads
  • Configuration files
  • Data storage

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • What is the main syntax difference between a standard JavaScript Object and valid JSON?

intermediate

  • Can you store a JavaScript `Function` or a `Date` object directly inside JSON?

Flash Cards

Question

Syntax difference?

Click to reveal answer
Answer

In JSON, ALL keys (property names) MUST be wrapped in double quotes (e.g., `"name": "John"`). Single quotes are forbidden.

Question

Store functions or dates?

Click to reveal answer
Answer

No! JSON is strictly text. It only supports Strings, Numbers, Booleans, Null, Arrays, and nested Objects. To store a Date, you must convert it to an ISO string first (`"2024-05-23T00:00:00Z"`). Functions cannot be serialized at all.