On the outermost level, a JSON object starts with a { and end with a }.

Sample data:

{
    "cars": {
        "Nissan": [
            {"model":"Sentra", "doors":4},
            {"model":"Maxima", "doors":4},
            {"model":"Skyline", "doors":2}
        ],
        "Ford": [
            {"model":"Taurus", "doors":4},
            {"model":"Escort", "doors":4}
        ]
    }
}

If the JSON is assigned to a variable called data, then accessing it would be like the following:

data.cars['Nissan'][0].model   // Sentra
data.cars['Nissan'][1].model   // Maxima
data.cars['Nissan'][2].doors   // 2

for (var make in data.cars) {
    for (var i = 0; i < data.cars[make].length; i++) {
        var model = data.cars[make][i].model;
        var doors = data.cars[make][i].doors;
        alert(make + ', ' + model + ', ' + doors);
    }
}

Another approach (using an associative array for car models rather than an indexed array):

{
    "cars": {
        "Nissan": {
            "Sentra": {"doors":4, "transmission":"automatic"},
            "Maxima": {"doors":4, "transmission":"automatic"}
        },
        "Ford": {
            "Taurus": {"doors":4, "transmission":"automatic"},
            "Escort": {"doors":4, "transmission":"automatic"}
        }
    }
}

data.cars['Nissan']['Sentra'].doors   // 4
data.cars['Nissan']['Maxima'].doors   // 4
data.cars['Nissan']['Maxima'].transmission   // automatic

for (var make in data.cars) {
    for (var model in data.cars[make]) {
        var doors = data.cars[make][model].doors;
        alert(make + ', ' + model + ', ' + doors);
    }
}

Edit:

Correction: A JSON object starts with { and ends with }, but it's also valid to have a JSON array (on the outermost level), that starts with [ and ends with ].

Also, significant syntax errors in the original JSON data have been corrected: All key names in a JSON object must be in double quotes, and all string values in a JSON object or a JSON array must be in double quotes as well.

See:

  • JSON specification
  • JSONLint - The JSON validator
Answer from Matt Coughlin on Stack Overflow
Top answer
1 of 6
188

On the outermost level, a JSON object starts with a { and end with a }.

Sample data:

{
    "cars": {
        "Nissan": [
            {"model":"Sentra", "doors":4},
            {"model":"Maxima", "doors":4},
            {"model":"Skyline", "doors":2}
        ],
        "Ford": [
            {"model":"Taurus", "doors":4},
            {"model":"Escort", "doors":4}
        ]
    }
}

If the JSON is assigned to a variable called data, then accessing it would be like the following:

data.cars['Nissan'][0].model   // Sentra
data.cars['Nissan'][1].model   // Maxima
data.cars['Nissan'][2].doors   // 2

for (var make in data.cars) {
    for (var i = 0; i < data.cars[make].length; i++) {
        var model = data.cars[make][i].model;
        var doors = data.cars[make][i].doors;
        alert(make + ', ' + model + ', ' + doors);
    }
}

Another approach (using an associative array for car models rather than an indexed array):

{
    "cars": {
        "Nissan": {
            "Sentra": {"doors":4, "transmission":"automatic"},
            "Maxima": {"doors":4, "transmission":"automatic"}
        },
        "Ford": {
            "Taurus": {"doors":4, "transmission":"automatic"},
            "Escort": {"doors":4, "transmission":"automatic"}
        }
    }
}

data.cars['Nissan']['Sentra'].doors   // 4
data.cars['Nissan']['Maxima'].doors   // 4
data.cars['Nissan']['Maxima'].transmission   // automatic

for (var make in data.cars) {
    for (var model in data.cars[make]) {
        var doors = data.cars[make][model].doors;
        alert(make + ', ' + model + ', ' + doors);
    }
}

Edit:

Correction: A JSON object starts with { and ends with }, but it's also valid to have a JSON array (on the outermost level), that starts with [ and ends with ].

Also, significant syntax errors in the original JSON data have been corrected: All key names in a JSON object must be in double quotes, and all string values in a JSON object or a JSON array must be in double quotes as well.

See:

  • JSON specification
  • JSONLint - The JSON validator
2 of 6
23

A good book I'm reading: Professional JavaScript for Web Developers by Nicholas C. Zakas 3rd Edition has the following information regarding JSON Syntax:

"JSON Syntax allows the representation of three types of values".

Regarding the one you're interested in, Arrays it says:

"Arrays are represented in JSON using array literal notation from JavaScript. For example, this is an array in JavaScript:

var values = [25, "hi", true];

You can represent this same array in JSON using a similar syntax:

[25, "hi", true]

Note the absence of a variable or a semicolon. Arrays and objects can be used together to represent more complex collections of data, such as:

{
    "books":
              [
                {
                    "title": "Professional JavaScript",
                    "authors": [
                        "Nicholas C. Zakas"
                    ],
                    "edition": 3,
                    "year": 2011
                },
                {
                    "title": "Professional JavaScript",
                    "authors": [
                        "Nicholas C.Zakas"
                    ],
                    "edition": 2,
                    "year": 2009
                },
                {
                    "title": "Professional Ajax",
                    "authors": [
                        "Nicholas C. Zakas",
                        "Jeremy McPeak",
                        "Joe Fawcett"
                    ],
                    "edition": 2,
                    "year": 2008
                }
              ]
}

This Array contains a number of objects representing books, Each object has several keys, one of which is "authors", which is another array. Objects and arrays are typically top-level parts of a JSON data structure (even though this is not required) and can be used to create a large number of data structures."

To serialize (convert) a JavaScript object into a JSON string you can use the JSON object stringify() method. For the example from Mark Linus answer:

var cars = [{
    color: 'gray',
    model: '1',
    nOfDoors: 4
    },
    {
    color: 'yellow',
    model: '2',
    nOfDoors: 4
}];

cars is now a JavaScript object. To convert it into a JSON object you could do:

var jsonCars = JSON.stringify(cars);

Which yields:

"[{"color":"gray","model":"1","nOfDoors":4},{"color":"yellow","model":"2","nOfDoors":4}]"

To do the opposite, convert a JSON object into a JavaScript object (this is called parsing), you would use the parse() method. Search for those terms if you need more information... or get the book, it has many examples.

🌐
RestfulAPI
restfulapi.net › home › json › json array
JSON Array - Multi-dimensional Array in JSON
November 4, 2023 - JSON Array is a list of items surrounded by square brackets. Each item in the array is separated by a comma. Learn about multi-dimensional arrays.
Discussions

How can i create a Json array from a group of arrays
I want to create the below json array from a group of arrays what would be the best way to go about this. i tried a for each loop but it overwrites the first instance. “CompaniesInfo”: [ { “CompanyId”: 138, “CompanyInfo”: { “Score”: “123”, “DocumentKey”: “76149”, ... More on forum.uipath.com
🌐 forum.uipath.com
4
0
February 7, 2023
How to read from Json with Multiple Arrays?

Your readPermissions property is an object with one array (data). Your array contains 2 elements.

I recommend start reading and practising some basics about data types in typescript/javascript.

But to answer your question:

<div *ngFor="let p of readPermissions.data> should do the trick.
More on reddit.com
🌐 r/angular
4
1
February 3, 2023
JSON Array with multiple json objects and json arrays
hello, I made an API call and I got a json response. I deserialized the json response, so that I have a json object. Now I want to extract some information from the object, but I have not managed to do it. Here is my j… More on forum.uipath.com
🌐 forum.uipath.com
6
0
October 27, 2021
Decoding an array of arrays from JSON data
If you implement custom encode / decode methods for ResultArray you can do it. Let's suppose you have: struct Album { ... init(_ values: [String]) { ... } } that initializes an Album with an array of strings in a particular order. Then in ResultArray you can do this (for the decode, the encode is just this in reverse): struct ResultArray : Codable { public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) self.majorDimension = try values.decode(String.self, forKey: . majorDimension) self.range = try values.decode(String.self, forKey: .range) var albums = [Album]() // this will consume the array of string arrays let allAlbumValues = try values.decode([[String]].self, forKey: .values) // then we can convert that to an array of Albums for albumValues in allAlbumValues { albums.append(Album(albumValues)) } // note: if you want to have different property names than the keys in the json you can use CodingKeys self.values = albums } } Something like that. More on reddit.com
🌐 r/swift
6
1
June 24, 2020
🌐
CodeSignal
codesignal.com › learn › courses › parsing-json-with-csharp › lessons › parsing-json-arrays-and-nested-structures
Parsing JSON Arrays and Nested Structures
Similarly to parsing simple JSON arrays, we can handle nested structures where arrays contain further arrays or objects. This nesting adds complexity but allows for a richer and more detailed representation of data.
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
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. ... List validation: a sequence of arbitrary length where each item matches the same schema.
🌐
Leapcell
leapcell.io › blog › understanding-json-arrays-of-arrays
Understanding JSON Arrays of Arrays | Leapcell
July 25, 2025 - This nesting allows for the organization of data in a tabular or matrix-like format. ... In this example, the matrix key holds an array containing three arrays, each representing a row in the matrix. JSON arrays of arrays are particularly useful in scenarios such as:
🌐
W3Schools
w3schools.com › js › js_json_server.asp
JSON Arrays
If the file contains a JSON array, response.json() returns a JavaScript array.
Find elsewhere
🌐
Codefinity
codefinity.com › courses › v2 › d797f15f-39dd-4abc-8cfd-0d898dd2b885 › 372339e2-bcc5-490c-a5ee-f4d51f680045 › e304b41b-64c3-4141-9977-18b5c16467ff
Learn JSON Arrays and Nested Objects | Understanding JSON Data
JSON arrays allow you to group multiple items together using square brackets []. Each item inside a JSON array can be a simple value, such as a number or string, or a more complex object.
🌐
Liquid-technologies
blog.liquid-technologies.com › advanced-data-structures-in-json-part-3-of-4
Advanced Data Structures in JSON: Nested Objects & Arrays
July 4, 2025 - Representing lists of similar items: A list of products, a collection of user records, a series of log entries. Maintaining order: JSON arrays are ordered, so the sequence of objects is preserved.
🌐
UiPath Community
forum.uipath.com › help › activities
How can i create a Json array from a group of arrays - Activities - UiPath Community Forum
I want to create the below json array from a group of arrays what would be the best way to go about this. i tried a for each loop but it overwrites the first instance. “CompaniesInfo”: [ { “CompanyId”: 138, “CompanyInfo”: { “Score”: “123”, “DocumentKey”: “76149”, ...
Published: February 7, 2023
🌐
Qlik Community
community.qlik.com › t5 › Design-and-Development › Multiple-Arrays-in-Json-Object › m-p › 2377484
Multiple Arrays in Json Object - Qlik Community - 2377484
January 6, 2022 - Hi Team, I am having Json object with Multiple arrays in it, i want to flatten all columns in one table. Attaching the sample Json file. We tried to put one sub job for each array and do lookup but it couldn't work it was giving like cross join. Please suggest on this. Thanks in advance.
🌐
NestJS
docs.nestjs.com › controllers
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
🌐
W3Resource
w3resource.com › JSON › structures.php
JSON Structures | JSON tutorial | w3resource
String and value is separated by a ':' and if there are more than one string value pairs, they are separated by ','. ... In JSON, objects can nest arrays (starts and ends with '[' and ']') within it.
🌐
React
react.dev › learn › rendering-lists
Rendering Lists – React
You will often need to show several instances of the same component using different data when building interfaces: from lists of comments to galleries of profile images. In these situations, you can store that data in JavaScript objects and arrays and use methods like map() and filter() to render lists of components from them.
🌐
TOOLSQA
toolsqa.com › rest-assured › what-is-json
What is JSON, JSON Object and JSON Array?
Arrays are similar to Arrays that you know from any other programming language. In JSON an Array is collection of Values separated by Comma.
🌐
Medium
medium.com › @harshadawayal4949 › json-array-json-object-6ea512b1f66c
JSON Array & JSON Object | by Harshada Wayal | Medium
March 22, 2024 - JSON data is represented as key-value pairs, similar to how objects are represented in JavaScript. Keys are always strings and values can be of following data types- ... JSON Arrays are very similar to arrays in JavaScript.
🌐
UiPath Community
forum.uipath.com › help › studio
JSON Array with multiple json objects and json arrays - Studio - UiPath Community Forum
October 27, 2021 - hello, I made an API call and I got a json response. I deserialized the json response, so that I have a json object. Now I want to extract some information from the object, but I have not managed to do it. Here is my json response: { “results”: [ { “group”: { “mediaType”: “chat”, “queueId”: “7a982920-3a-4083-8315-db0f5fec6c44” }, “data”: [ { “interval”: “2021-08-16T00:00:00.000Z/2021-08-22T00:00:00.000Z”, “metrics”: [ { “metric”: “tAcw”, “stats”: { “max”: 800000, “min”: 6000, ...
🌐
Pydantic
docs.pydantic.dev › latest › concepts › models
Models | Pydantic Docs
You can think of models as similar ... of a single endpoint in an API. Models share many similarities with Python’s dataclasses, but have been designed with some subtle-yet-important differences that streamline certain workflows related to validation, serialization, and JSON schema ...
🌐
Surfsidemedia
surfsidemedia.in › post › how-do-you-create-a-json-array
How do you create a JSON array - Surfside Media
A JSON array is an ordered list of values that can contain multiple data types, including strings, numbers, objects, arrays, booleans, and null. JSON arrays are defined using square brackets [], and the values within the array are separated by commas.