Automate the busywork

JSON Basics for People Who Automate

JSON is a plain-text format for organizing data into named fields, and it is what most APIs use to send and receive information. A JSON object is a set of keys and values wrapped in curly braces. Once you can read a small JSON example, you can follow the data moving through nearly any automation.

You do not need to be a programmer. Automation tools show JSON in friendly forms, but sooner or later you will meet the raw text, usually when you are tracking down why a step failed. Knowing the basics turns that moment from confusing into routine.

What JSON looks like

Here is a small example, described in words. An object for a customer has a field called “name” with the text “Ana Costa,” a field called “email” with an address, and a field called “active” with the value true.

In JSON, each field is a key in double quotes, followed by a colon, followed by its value. Fields are separated by commas, and the whole set is wrapped in curly braces.

Keys are always text in double quotes. Single quotes are not valid. This catches many people the first time they type JSON by hand.

The six kinds of values

A value in JSON can be one of only a few types.

The difference between “42” in quotes and 42 without is easy to miss. The first is text and the second is a number. Some services reject one when they expect the other.

Objects inside objects

Real data is rarely flat. A customer might have an address, and the address has a street, a city and a postal code. In JSON, the address is a value that is itself an object.

To reach the city, you follow a path: customer, then address, then city. Many tools write this as customer.address.city. When a no-code tool asks you to map a field, it is asking for exactly this path.

Getting the path right is the most common stumbling block. If a step says a value is empty, check whether you are pointing at the right level of nesting.

Arrays: lists of things

When an API returns several items, they arrive in an array. A list of orders is an array of objects, each one an order, separated by commas inside square brackets.

To get one item, you refer to its position, counting from zero. The first order is position 0, the second is position 1. A path such as orders[0].total means the total of the first order.

Automation tools usually offer a loop that goes through each item in an array. If you receive an array and your step expects a single object, the step may fail or process only the first item.

Common mistakes that break things

Small slips in JSON cause a surprising number of failures. Watch for these.

Most of these are easy to catch with a JSON validator. Paste your text in and it points to the line with the problem. Many code editors do the same.

Empty and missing values

APIs often leave out fields that have no value, or return null. Your automation needs to cope with both. If a customer has no phone number, a step that tries to use the phone number may fail or send an empty message.

Add a check before using optional fields. If the value is missing, skip the step, use a default, or stop and flag it. This single habit eliminates many “it worked yesterday” mysteries.

Building JSON for a request

When you send data to an API, you may need to write JSON yourself. Keep it tidy: put each field on its own line, indent nested objects, and match the field names exactly as the documentation spells them. Names are case sensitive, so “Email” and “email” are different keys.

If values come from earlier steps, insert them carefully. A name containing an apostrophe or quotation mark can break a hand-built string. Where possible, let the tool build the JSON from fields instead of joining text yourself.

Reading a response with a purpose

When you receive a large response, do not try to understand everything. Find the three or four fields your next step needs, and note their paths. Ignore the rest.

Look at the structure first: is the top level an object or an array? Is the data you want inside a wrapper field named “data” or “results”? Many APIs wrap their results, and the path begins one level down.

Dates deserve a short warning. JSON has no date type, so dates travel as text, and services disagree on the format. One might send a year-month-day string with a time zone, another might send a number of seconds since a fixed moment. When a date looks wrong in a later step, check the format first and convert it explicitly.

Your next step

Take a real response from an API you use, or copy a sample from its documentation, and paste it into a JSON viewer. Practice writing the path to three fields, including one inside an array.

Then break it on purpose by deleting a closing brace and see what the validator says. That small exercise makes error messages familiar and saves real time the next time a flow fails.