The second is almost correct:

{
    "foos" : [{
        "prop1":"value1",
        "prop2":"value2"
    }, {
        "prop1":"value3", 
        "prop2":"value4"
    }]
}
Answer from Justin Niessner on Stack Overflow
Top answer
1 of 7
3

Lean towards option 1, as it's a more expected format.

Option 1 works with JSON as it's designed to be used and therefore benefits from what JSON offers (a degree of human readability, which is good for debugging, and straightforward parsing, which is good for limiting entire categories of bugs to begin with).

Option 2 begrudgingly adopts JSON and subverts many of the benefits. If you don't want human readability, use protobuf or something similar... AIWalker's "CSV"-like approach isn't terrible either. It is marginally better (readable) than splitting objects apart and recombining them. But, this is still not as good (readable) as using JSON "as designed".

Also bear in mind, your API responses are also likely going to be gzipped. Most of the repetition in option 1 will be quickly and transparently condensed over the wire.

As an aside, if you're moving a lot of data, also consider JSONL or paginated results. Pagination can be especially helpful for web clients, as it places natural pauses in the processing, providing a degree of "organic" protection against UI lockups.

2 of 7
3

A list of objects is easier to work with. You can use append, map, filter... All the nice things JS Arrays have which manual indexing doesn't. And there's no way to get out of sync, so that's an entire class of bugs gone.

If you're worried about efficiency:

  • Measure (premature optimization is the root of all evil)
  • Consider the list of lists trick AIWalker proposed
  • Consider an outright binary format
  • Make sure gzip is enabled
  • Measure (it's worth saying twice)
🌐
W3Schools
w3schools.com › js › js_json_server.asp
W3Schools.com
The Content-Type header tells the server what type of data is being sent. ... The value application/json tells the server that the request body contains JSON. The request body must contain text, not a JavaScript object.
🌐
W3Resource
w3resource.com › JSON › structures.php
JSON Structures | JSON tutorial | w3resource
JSON supports two widely used (amongst programming languages) data structures. A collection of name/value pairs. Different programming languages support this data structure in different names. Like object, record, struct, dictionary, hash table, keyed list, or associative array.
🌐
Adobe
opensource.adobe.com › Spry › samples › data_region › JSONDataSetSample.html
JSON Data Set Sample
The examples on this page attempt to illustrate how the JSON Data Set treats specific formats, and gives examples of the different constructor options that allow the user to tweak its behavior. See our JSON Primer for more information. Example 1 - JSON Array with simple data types as elements. ... Example 4 - The "path" constructor option. Example 5 - The "path" constructor option and JSON Array with objects as elements.
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
Arrays are used for ordered elements. In JSON, each element in an array may be of a different type. Language-specific info: Python · Ruby · Objective-C · Swift · In Python, "array" is analogous to the list or tuple type, depending on usage. However, the json module in the Python standard library will always use Python lists to represent JSON arrays.
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
1 week ago - JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or vice versa). You'll come across it quite often, so in this article, we give you all you need to work with JSON using JavaScript, including parsing JSON so you can access data within it, and creating JSON.
🌐
CodeSignal
codesignal.com › learn › courses › parsing-json-with-csharp › lessons › parsing-json-arrays-and-nested-structures
Parsing JSON Arrays and Nested Structures
A JSON array is a collection of ordered items enclosed in square brackets, [ ]. Each item in an array could be an object, a string, a number, or even another array. JSON arrays are used to store lists or sequences.
🌐
Unity
discussions.unity.com › unity engine
How can I turn JSON String into a list of objects based on number of items. - Unity Engine - Unity Discussions
May 15, 2020 - Hey there, I am receiving a JSON string from the backend of my webserver. I managed to create a class for User profile and mapped it with the exact fields as its JSON string. Unfortunately the Items JSON string has neste…
🌐
HashiCorp Discuss
discuss.hashicorp.com › terraform
How to create a list of map objects within a JSON object using for....in loop - Terraform - HashiCorp Discuss
December 18, 2023 - We are trying to create below mentioned JSON in terraform. Basically list of map objects Currently we are trying to use for…in loop which is iterating over a list of map (i.e. list(map(string)). Can someone please shar…
🌐
JSON
json.org › example.html
JSON Example
{"web-app": { "servlet": [ { "servlet-name": "cofaxCDS", "servlet-class": "org.cofax.cds.CDSServlet", "init-param": { "configGlossary:installationAt": "Philadelphia, PA", "configGlossary:adminEmail": "ksm@pobox.com", "configGlossary:poweredBy": "Cofax", "configGlossary:poweredByIcon": "/images/cofax.gif", "configGlossary:staticPath": "/content/static", "templateProcessorClass": "org.cofax.WysiwygTemplate", "templateLoaderClass": "org.cofax.FilesTemplateLoader", "templatePath": "templates", "templateOverridePath": "", "defaultListTemplate": "listTemplate.htm", "defaultFileTemplate": "articleTem
🌐
OpenAI Developers
developers.openai.com › api › docs › guides › structured-outputs
Structured model outputs | OpenAI API
JSON is one of the most widely used formats in the world for applications to exchange data. Structured Outputs is a feature that ensures the model will always generate responses that adhere to your supplied JSON Schema, so you don’t need to worry about the model omitting a required key, or hallucinating an invalid enum value.
🌐
Spiceworks
spiceworks.com › spiceworks inc › soft-tech › json types, functions, and uses with examples - spiceworks inc
JSON Types, Functions, and Uses with Examples
December 16, 2025 - The curly bracket contains the object and is separated from the name by a colon. Square brackets hold arrays, and a comma separates the array from values. ... An ordered list of values, which translates to arrays, vectors, lists, or sequences.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-json-array
What is JSON Array? - GeeksforGeeks
July 23, 2025 - JSON array can store values of type string, array, boolean, number, object, or null. In JSON array, values are separated by commas.
🌐
GitHub
gist.github.com › fatihacet › 4247503
Sample array of object json · GitHub
Sample array of object json. GitHub Gist: instantly share code, notes, and snippets.
🌐
Website-files
assets-global.website-files.com › 66f3e78573886ea1086879bb › 67c3dce50bb6ac91e898fab2_81670121993.pdf pdf
Json list of values
JSON lists are an essential part of the lightweight data-interchange format, making it easy for humans to read and write and simple for machines to parse and generate. A JSON list is essentially an array structure that holds multiple JSON objects or values.
🌐
JSON Formatter
jsonformatter.org › json-parser
JSON Parser Online to parse JSON
Secure JSON Parser is an online JSON Parser tool to Parse, Decode and Visualize JSON data in Tree view. JSON Parser online updated in 2022.
🌐
Swagger
swagger.io › specification
OpenAPI Specification - Version 3.2 | Swagger
Patterned fields MUST have unique ... object. Note: While APIs may be described by OpenAPI Descriptions in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML. In order to preserve the ability to round-trip between YAML and JSON formats, YAML version 1.2 is RECOMMENDED along with the additional constraints listed in [[!RFC9512]] Section 3.4. The recommendation in previous versions of this specification ...