JSON Essentials: Key Concepts and Usage Explained

In modern software development, applications constantly exchange data between clients and servers. For years, XML was the preferred format for this task until JSON emerged as a simpler, more lightweight, and easier-to-read alternative.

In this article, you’ll learn the essentials of JSON: what it is, how it works, and why it has become a fundamental tool in today’s development and testing workflows.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data format derived from JavaScript. Despite its origin, it’s language-independent and supported by almost every programming languages, including Python, Java, PHP, Ruby, and many others.

Its main purpose is to provide a standardized way to encode structured data, making it easy to store and transfer across systems. JSON itself doesn’t “do” anything on its own, it’s simply a format, like a well-organized text file that describes data.

While is inspired by JavaScript object syntax, a JSON it’s not the same as a JavaScript object. If you’re writing code, especially in JavaScript, it’s important to understand their differences to avoid unexpected issues when working with each.

What is it used for?

JSON is widely used in modern software systems for a variety of purposes:

  • Data interchange: The most common use, especially for exchanging information between clients and servers through REST APIs and similar protocols.
  • Configurations file: Many configuration files in web and backend projects are written in JSON. Some examples include: package.json, tsconfig.json, postman-collection.json, etc.
  • Data storage: JSON is also used for simple data persistence in some cases. For example, storing user preferences or exporting data from one system to be imported into another.

JSON Structure and Data Types

JSON represents data using key-value pairs, similar to dictionaries or maps in many programming languages.

  • The key (or property name) is always a string and must be enclosed in double quotes.
  • The value can be one of these types:
    • String
    • Number
    • Boolean
    • Object (another set of key-value pairs)
    • Array (a list of values)
    • Null

While these types may seem limited, they are enough to represent highly complex data structures through nesting.

Basic Syntax Rules

  • Keys must be in double quotes.
  • Key-value pairs are separated by a colon :.
  • Multiple pairs are separated by a comma ,.
  • The data is wrapped either in:
    • Curly braces {} → for objects.
    • Square brackets [] → for arrays (lists).

Comments (Like // or /* */) are not allowed in standard JSON, although some parsers support unofficial workarounds.

A Simple JSON Object Example

{
    "name": "Jon Snow",
    "age": 25,
    "city": "The Wall"
}

This is a JSON object with three key-value pairs. It can be treated as a string in most programming languages and parsed accordingly.

A JSON Array Example

[
    {
        "name": "Alex C",
        "age": 2,
        "city": "Houston"
    },
    {
        "name": "John G",
        "age": 40,
        "city": "Washington"
    }
]

This is a JSON array of objects. Each object represents a record or entity, commonly used in APIs to return lists of items.

A practical example

Let’s take everything we’ve covered so far and analyze a practical JSON structure to see how it’s built and how each piece fits in.

A basic JSON object

{
  "name": "pencils",
  "code": "PP004",
  "order": {
    "order_number": 100234,
    "date": "2025-01-01",
    "quantity": 2
  }
}

This JSON object describes a product and includes an embedded order. Here’s a breakdown of the structure:

  • “name”: The product name, represented as a string.
  • “code”: A unique alphanumeric identifier for the product.
  • “order”: This is a nested object representing details of a specific order. It includes:
    • “order_number”: The ID of the order (number).
    • “date”: The date the order was placed. It’s stored as a string, although the content is a date.
    • “quantity”: The number of items ordered, also a number.

This example showcases how we can combine different JSON data types (string, number, object) and use nesting to represent related entities (e.g., a product and its order) in a clean and structured way.

More Complex: JSON Array with Nested Objects

[ 
  {
    "name": "pencils",
    "code": "PP004",
    "order": {
        "order_number": 100234,
        "date": "2025-01-01",
        "quantity": 2
    }
  },
  {
    "name": "school bag",
    "code": "PSB001",
    "order": {
      "order_number": 100235,
      "date": "2025-01-03",
      "quantity": 1
    }
  }
]

This is a JSON array, denoted by the square brackets []. Each item inside the array is a JSON object representing a product with an associated order. Let’s break it down:

  • “name”: A string representing the product’s name.
  • “code”: An alphanumeric string acting as a unique identifier.
  • “order”: A nested object containing order-specific data:
    • “order_number”: The order ID.
    • “date”: The date when the order was placed (stored as a string).
    • “quantity”: The number of items ordered.

This example showcases how to combine objects and arrays. JSON can represent structured collections of complex data while remaining lightweight and easy to process.

If you want to go deeper take a look at the official JSON Website https://www.json.org/json-en.html

JSON vs JavaScript Objects: Key Differences

Though JSON is inspired by JavaScript object notation, there are a few important differences to keep in mind—especially if you’re working in JavaScript.

FeatureJSONJavaScript Object
Keys must be in double quotes
Can contain functions/methods
Allows comments
Is language-independent

Understanding the distinction helps when working with APIs, test automation tools, or when debugging data handling in your apps.

Final Thoughts

JSON is a simple yet powerful format that plays a key role in software development and QA because it’s simple, readable, lightweight, and widely supported. JSON is especially valuable for communication over APIs, making it an essential skill for modern software workflows.

Thank you for reading, and happy coding!