JSON Array: Check Empty, Single and Multiple Records
Check the shape of a JSON array, distinguish it from an object, and test how an export handles empty, single and multiple records.

Use an array when a field represents a list
A JSON array is an ordered list enclosed in square brackets. Each entry can be a JSON value, including an object or another array. An object enclosed in braces represents named properties. If an interface expects an array of records, it should still receive an array when there is just one record. Treat structure as part of the exchange contract, not a formatting preference.
Test all three record counts
| Case | Example | Expected interpretation |
|---|---|---|
| No results | {"items":[]} | The list exists and contains no items |
| One result | {"items":[{"id":"0042"}]} | A list containing one object |
| Two results | {"items":[{"id":"0042"},{"id":"0061"}]} | Two items in the stated order |
An export that returns {"items":{"id":"0042"}} for the second case has changed the type from list to object. This is valid JSON syntax, but it violates a contract that requires items to be an array. A consumer that handles ten records can fail on one record. Fix that at the producer or apply a documented conversion specific to the field. Avoid a blanket rewrite of every object in the response.
Separate empty, null and absent
An empty array is an explicit list with no entries. A null value may mean the producer does not know the list or the field is not applicable. An absent property means no value was sent for that key. The receiving contract, not JSON syntax, decides whether those cases are allowed or interchangeable. Preserve the distinction in the sample set until both sides agree to a mapping.
Check the kind of record the receiver wants
Consider a shipment object containing a list of packages. An application looking up shipments may want one record for each shipment. A warehouse report may need one row for each package. If you flatten the latter, keep the parent shipment ID in every package row. Two packages with quantities of two and three should produce two package rows and a total of five; the shipment count remains one.
Validate shape before sending a whole export
Check that the receiver uses the right path, that the chosen path holds an array, and that each entry has the expected fields and types. Include an empty array, a single item and multiple items in the sample. Record any fields the receiver drops during import. If the producer allows mixed entry types, ask whether the receiving system does too before relying on the first record as the template.
Questions about JSON arrays
Can the top-level JSON value be an array? Yes, but use a top-level array only when the receiving contract expects one; some APIs require a surrounding object.
Does an array give each item a unique ID? No. Values have positions in the array, not unique identifiers. Use an explicit ID when the task needs to track a record across exports.
Choose the handoff format after the structure passes
Send the verified sample and a short note listing the array path, each edge case and the expected record count. If the next step is a table, agree on a row definition before export. If the next step is another application, keep the native array and ask the consumer to run the same fixtures.
Related reading: How to Open a JSON File and Check Its Contents, including the steps for inspecting a file locally.

