If APIs are the messengers of the web, JSON is the letter they carry. Understanding how to read, write, and extract data from JSON is the most important technical skill for any automation architect.
1The Anatomy of JSON
JSON is essentially a collection of Key-Value Pairs. The key acts as a descriptive label (like email_address), and the value is the actual data (like [email protected]).
These pairs are grouped into Objects (using { }) or Arrays (using [ ]). Objects are used for structured data where each piece of information has a specific name. Mastering the mental model of 'drilling down' through these layers is how you navigate the complex responses returned by modern web services. When your automation receives a webhook, it receives it as a JSON Object.
// Anatomy of a JSON Object
{
"first_name": "Alex",
"status": "active",
"lifetime_value": 4500
}2The Zero-Index Rule
One of the most common points of confusion for beginners is Zero-Based Indexing. In programming, we don't start counting at 1; we start at 0.
If an API returns a list of three customers in an array, the first customer is at position [0], the second at [1], and the third at [2]. Forgetting this rule often leads to 'Undefined' errors or fetching the wrong piece of data. In n8n, you can see these indexes clearly in the execution data view, helping you map the correct values to your subsequent nodes.
// Navigating a JSON Array
{
"recent_purchases": [
"Laptop",
"Mouse",
"Keyboard"
]
}