Showing posts with label Structured Data. Show all posts
Showing posts with label Structured Data. Show all posts

Friday, September 18, 2026

What Is JSON?

// data formats

What Is JSON?

JSON is a lightweight text-based format for representing structured data. It is widely used by websites, APIs, applications and programming languages to exchange information in a form that is relatively easy for both humans and computers to understand.

// definition

JSON means JavaScript Object Notation

JSON stands for JavaScript Object Notation.

It is a text-based format used to represent structured information using objects, arrays, names and values.

Although JSON originated from JavaScript syntax, it is now used independently by many programming languages and software systems.

// example

What does JSON look like?

Suppose we want to store information about a customer.

{ "name": "Alice Smith", "email": "alice@example.com", "orders": 4, "active": true }

This is a JSON object.

Each piece of information consists of a name and a value.

// name-value pairs

JSON uses name-value pairs

Consider this line:

"name": "Alice Smith"

The name of the property is:

"name"

and its value is:

"Alice Smith"

A colon separates the property name from its value. Commas separate different properties.

// objects

JSON objects use curly braces

An object begins with { and ends with }.

{ "product": "Keyboard", "price": 49.99, "stock": 12 }

Objects are useful when several named properties belong to the same thing.

// arrays

JSON arrays use square brackets

An array represents an ordered collection of values.

[ "HTML", "CSS", "JavaScript", "PHP" ]

Arrays begin with [ and end with ].

// collections

Arrays can contain objects

This is extremely common when working with APIs and databases.

[ { "name": "Alice", "orders": 4 }, { "name": "Ben", "orders": 7 }, { "name": "Carla", "orders": 2 } ]

Here, the array contains three separate customer objects.

// data types

JSON supports several kinds of values

Type Example
String "Freelance Coder"
Number 42
Boolean true
Null null
Object { "name": "Alice" }
Array [1, 2, 3]
// strings

JSON strings use double quotation marks

{ "city": "London" }

JSON requires strings and property names to use double quotation marks.

Important: JSON does not allow property names or strings to be written using single quotation marks in standard JSON syntax.

// boolean values

JSON can represent true and false

{ "active": true, "verified": false }

Boolean values are written without quotation marks.

// null

JSON can represent no value

{ "middleName": null }

The value null represents the intentional absence of a value.

// nesting

JSON can represent complex structures

Objects can contain other objects and arrays.

{ "customer": { "name": "Alice", "location": { "city": "Birmingham", "country": "United Kingdom" }, "orders": [ { "id": 1001, "total": 49.99 }, { "id": 1002, "total": 25.50 } ] } }

This creates a hierarchical structure in which related information can be grouped together.

// APIs

JSON is widely used by APIs

One of JSON's most important uses is transferring data between software systems.

For example, an application might request information about a product from an API and receive:

{ "id": 1042, "name": "Wireless Keyboard", "price": 39.99, "available": true }

The application can then read the JSON and use the values in its own interface or processing.

// data exchange

JSON helps systems communicate

Website ↓ API request ↓ Server ↓ JSON response ↓ Website

JSON provides a common structure that both sides can understand.

// json vs csv

JSON and CSV solve different problems

CSV works particularly well for simple tabular data.

Name,Orders Alice,4 Ben,7

JSON can represent more complex nested structures.

{ "customers": [ { "name": "Alice", "orders": [ 1001, 1002 ] } ] }
CSV JSON
Rows and columns Objects and arrays
Excellent for tables Excellent for structured data
Flat structure Can be nested
// json vs xml

JSON and XML can represent similar data

This XML:

<customer> <name>Alice</name> <orders>4</orders> </customer>

could be represented in JSON as:

{ "customer": { "name": "Alice", "orders": 4 } }

JSON is often more compact for application data, while XML provides additional features that can be useful for document-oriented and specialised systems.

// plain text

JSON is a text format

JSON may represent complex information, but the underlying document is still text.

This means JSON can be opened in a text editor, transmitted over a network and processed by many different programming languages.

Text-Based Structured Portable Machine-Readable Human-Readable
// utf-8

JSON and UTF-8

JSON exchanged between systems is commonly encoded using UTF-8.

{ "name": "João", "currency": "£", "symbol": "π", "message": "Olá" }

UTF-8 allows JSON to represent a very wide range of Unicode characters reliably.

// .json files

JSON can be stored in .json files

JSON data saved as a standalone file normally uses the .json file extension.

customers.json products.json settings.json data.json

JSON does not have to exist as a separate file, however. It can also be sent directly between applications and APIs.

// advantages

Why is JSON so widely used?

Readable

Its structure is relatively easy for people to inspect and understand.

Lightweight

JSON can represent structured information without large amounts of additional markup.

Structured

Objects, arrays and nested values can represent sophisticated data structures.

Widely supported

Most modern programming languages and web technologies can read and generate JSON.

// uses

Where is JSON used?

APIs Web Applications Databases Configuration Automation AI Systems Data Exchange JavaScript Mobile Apps Cloud Services
// syntax

JSON syntax is strict

Valid JSON must follow specific rules.

Property names use double quotes.

Strings use double quotes.

Properties are separated by commas.

Trailing commas are not permitted in standard JSON.

For example, this is valid:

{ "name": "Alice", "age": 30 }

But this is not valid standard JSON:

{ 'name': 'Alice', 'age': 30, }
// summary

Simple text. Structured information.

JSON is a text-based format for representing structured data using objects, arrays and name-value pairs. Its simplicity, flexibility and widespread software support make it one of the most important formats for APIs, websites, applications, automation and modern data exchange.

What Is XML?

// file formats

What Is XML?

XML is a text-based format for storing and exchanging structured information. It uses descriptive tags to show what each piece of data means and how different pieces of information relate to one another.

// definition

XML means Extensible Markup Language

XML stands for Extensible Markup Language.

It is a plain-text format designed to describe, organise, store and exchange structured information.

XML does this using tags that identify the meaning and structure of the data.

// example

What does XML look like?

Imagine that we want to store information about a customer.

<customer> <name>Alice Smith</name> <email>alice@example.com</email> <orders>4</orders> </customer>

The information is surrounded by tags such as <name>, <email> and <orders>.

These tags give meaning to the values rather than simply storing them in a fixed position.

// tags

Opening and closing tags

Most XML elements have an opening tag and a closing tag.

<name>Alice Smith</name>

Here:

<name>

This is the opening tag. It marks the beginning of the element.

</name>

This is the closing tag. The forward slash indicates the end of the element.

// structure

XML is hierarchical

One of XML's most important features is that elements can contain other elements.

This creates a tree-like hierarchy.

<shop> <customer> <name>Alice</name> <orders> <order> <id>1001</id> <total>49.99</total> </order> <order> <id>1002</id> <total>25.50</total> </order> </orders> </customer> </shop>

In this example, the shop contains a customer, the customer contains orders, and each order contains its own information.

// root element

An XML document needs a root element

A well-formed XML document has one outermost element that contains the rest of the document.

<customers> <customer> <name>Alice</name> </customer> <customer> <name>Ben</name> </customer> </customers>

Here, <customers> is the root element.

// attributes

XML elements can also have attributes

Attributes provide additional information about an element.

<customer id="1042" status="active"> <name>Alice Smith</name> </customer>

In this example:

id="1042" status="active"

These are attributes attached to the customer element.

// extensible

Why is XML called "extensible"?

XML does not give you a fixed set of tags.

Instead, you can create tags appropriate to the information you are describing.

<book> <title>Introduction to Data</title> <author>Jane Smith</author> </book>

A different system might use:

<product> <sku>ABC-100</sku> <price>29.99</price> </product>

The tags can therefore be designed around the type of information being stored.

// declaration

The XML declaration

XML documents may begin with a declaration such as:

<?xml version="1.0" encoding="UTF-8"?>

This tells software that the document uses XML version 1.0 and that the text is encoded using UTF-8.

Important: XML is a text format, so character encoding matters. UTF-8 is extremely common because it can represent characters from many languages and writing systems.

// escaping

Some characters need special handling

Because characters such as angle brackets are used as part of XML syntax, certain characters must be represented using special entity references when they are intended as data.

Character XML representation
< &lt;
> &gt;
& &amp;
" &quot;
' &apos;
// rules

XML has strict structural rules

XML must be well formed for an XML parser to process it correctly.

Tags must close

Elements normally need corresponding opening and closing tags.

Tags must nest correctly

Elements cannot overlap one another incorrectly.

One root element

The document must have one outermost root element.

XML is case-sensitive

<Name> and <name> are treated as different tags.

// nesting

Correct nesting matters

This is valid:

<customer> <name>Alice</name> </customer>

But this structure is invalid:

<customer> <name>Alice </customer> </name>

The elements have been closed in the wrong order.

// xml vs html

XML and HTML look similar, but they have different purposes

Both use angle-bracket tags, but they are designed for different jobs.

XML HTML
Describes and structures data Structures content for web pages
Custom tags can be created Uses predefined HTML elements
Focused on information Focused on webpage structure and presentation
Strict syntax Browsers are often more forgiving
<!-- XML --> <product> <name>Keyboard</name> <price>49.99</price> </product> <!-- HTML --> <h1>Keyboard</h1> <p>Price: £49.99</p>
// xml vs json

XML and JSON can represent similar information

XML and JSON are both commonly used to represent structured data.

For example, this XML:

<customer> <name>Alice</name> <orders>4</orders> </customer>

could be represented in JSON as:

{ "customer": { "name": "Alice", "orders": 4 } }

JSON is often more compact, while XML offers features such as attributes, namespaces and document-oriented structures that can be useful in more complex systems.

// uses

What is XML used for?

XML has been used extensively for exchanging and storing structured information across many kinds of software.

Configuration Files Data Exchange Web Services Document Formats Product Feeds Sitemaps RSS Feeds APIs Data Imports Data Exports
// real-world example

Website sitemaps commonly use XML

A website can provide an XML sitemap containing information about its pages.

<urlset> <url> <loc>https://example.com/</loc> </url> <url> <loc>https://example.com/about</loc> </url> </urlset>

Search engines and other software can process this structured information automatically.

// data management

Why XML matters in data management

XML allows information to describe its own structure.

Instead of relying purely on column positions or an external explanation, tags can identify what individual pieces of information represent.

<employee> <name>Tiago</name> <department>Technology</department> <active>true</active> </employee>

This makes XML useful when information needs to move between systems while retaining a clear hierarchical structure.

// plain text

XML is still plain text

Although XML can represent complex structures, the file itself is text.

This means an XML file can be opened in a text editor, inspected by a person and processed by software.

Readable Portable Structured Machine-Readable Text-Based
// summary

Text with structure and meaning.

XML is a text-based language for representing structured information. It uses tags, elements, attributes and hierarchical relationships to describe what data means and how different pieces of information fit together.

What Is an IP Address?

// networking What Is an IP Address? An IP address is a numerical address used t...