Understanding JSON and APIs

  • Admin
  • 1 min read

What is JSON?

JSON (JavaScript Object Notation) is a lightweight text format for representing structured data. It’s become the standard way applications exchange data over the web.

{ "id": 101, "title": "Learn Python", "tags": ["python", "beginner"], "published": true, "author": { "name": "Asha", "id": 7 } }

JSON Rules

  • Keys are always strings, wrapped in double quotes
  • Values can be strings, numbers, booleans, null, arrays, or nested objects
  • No trailing commas, no comments — unlike JavaScript object literals

What is an API?

An API (Application Programming Interface) is a defined way for one program to request data or actions from another. A REST API exposes data over HTTP using URLs and standard verbs.

Method Meaning
GET Retrieve data
POST Create new data
PUT/PATCH Update existing data
DELETE Remove data

Calling an API from JavaScript

const response = await fetch("https://api.example.com/tutorials/101"); const data = await response.json(); console.log(data.title);

Parsing and Creating JSON in Code

const obj = JSON.parse('{"name": "Asha"}'); // JSON text → object const text = JSON.stringify({ name: "Asha" }); // object → JSON text

Practice Exercise

Write a JSON object representing a tutorial (title, author, tags array, published boolean), then write JavaScript to fetch it from a mock API and log just the tags.

Admin

About the author

Admin

Instructor and technical writer at tutorials.in

Writes beginner lessons for tutorials.in. Each lesson is checked against the language or tool documentation, and examples are run before publishing.

Reviewed by the editorial team before publishing. Last updated August 9, 2026.

Ask a question

Be specific about what you tried. Questions with a code sample and the exact error message are answered fastest.