This isn't a single JSON object. You have an array of JSON objects. You need to loop over array first and then access each object. Maybe the following kickoff example is helpful:

var arrayOfObjects = [{
  "id": 28,
  "Title": "Sweden"
}, {
  "id": 56,
  "Title": "USA"
}, {
  "id": 89,
  "Title": "England"
}];

for (var i = 0; i < arrayOfObjects.length; i++) {
  var object = arrayOfObjects[i];
  for (var property in object) {
    alert('item ' + i + ': ' + property + '=' + object[property]);
  }
  // If property names are known beforehand, you can also just do e.g.
  // alert(object.id + ',' + object.Title);
}

If the array of JSON objects is actually passed in as a plain vanilla string, then you would indeed need eval() here.

var string = '[{"id":28,"Title":"Sweden"}, {"id":56,"Title":"USA"}, {"id":89,"Title":"England"}]';
var arrayOfObjects = eval(string);
// ...

To learn more about JSON, check MDN web docs: Working with JSON .

Answer from BalusC on Stack Overflow
🌐
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.
🌐
W3Schools
w3schools.com › js › js_json_arrays.asp
JSON Arrays
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... Arrays in JSON are almost the same as arrays in JavaScript. In JSON, array values must be of type string, number, object, array, boolean or null.
🌐
JSON Schema
json-schema.org › learn › miscellaneous-examples
JSON Schema - Miscellaneous Examples
The data example shows the usage of arrays. The fruits property contains an array of strings, while the vegetables property contains an array of objects, each adhering to the "veggie" schema definition.
🌐
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.
🌐
Codeblogmoney
codeblogmoney.com › json-example-with-data-types-including-json-array
JSON Example with Data Types Including JSON Array
July 3, 2018 - Valid JSON Data Types String Number Object Array Boolean Null 1. JSON String Example: 1 2 3 4 5 { "firstname": "Tom", "lastname": "Cruise", "occupation": "Actor" } This example shows information about a person, and you know Tom Cruise.
🌐
JSONata
docs.jsonata.org › simple
Simple Queries · JSONata
To support the extraction of values from a JSON structure, a location path syntax is defined. In common with XPath, this will select all possible values in the document that match the specified location path. The two structural constructs of JSON are objects and arrays.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-json-array
What is JSON Array? - GeeksforGeeks
July 23, 2025 - Example: Here we assign a JSON Array of Booleans to the key boolean in jsonBooleanArray object.
🌐
RestfulAPI
restfulapi.net › home › json › json array
JSON Array - Multi-dimensional Array in JSON
November 4, 2023 - { "name" : "Admin", "age" : 36, "rights" : [ "admin", "editor", "contributor" ] } You can access the array values by using the index number: ... Program output. ... Program output.
🌐
Reddit
reddit.com › r/csharp › create json with arrays of different types?
r/csharp on Reddit: Create JSON with Arrays of different types?
October 13, 2022 -

I am trying to make a JSON file using C#, and to make a simple one seems pretty easy. but on thing I am struggling with is an array. The entire file falls inside an array, and I can't seem to find documentation enough to make that happen though. Does anyone know how to do this?

Below I posted a link to an example of a JSON I would be interested in making. I created an object in C# that has every variable listed, but I don't know how to format it to have every variable listed in the correct spot. I appreciate any help. Thank you!

https://help.viewpoint.com/en/spectrum/spectrum/api-web-services/api-web-services/list-of-web-services/accounts-payable-services/vendor-invoice-multi-line

Edit: Does indentation matter in JSON? I suppose I could just hardcore a massive string and insert the variables as needed if that’s that case

Top answer
1 of 2
2
Let's go a bit out of order: Does indentation matter in JSON? No. The only things that matter in JSON are the few symbols it uses, it ignores whitespace outside of strings. But also: I don't know how to format it to have every variable listed in the correct spot. Order does not matter in JSON. That's why every property has a name. For the rest of it, here's a quick crash course. You didn't say how you're "making a JSON file". Usually in C# these days, we use a "serialization library". MS has one in I think the System.Text namespace, but before that existed everyone used a package called Newtonsoft.JSON. They both work roughly the same: they convert C# objects to and from JSON. So if I wrote a class like this: public class Example { public int Value { get; set; } } I'd write code (sort of, I'm not double-checking) like this with Newtonsoft: var example = new Example(); example.Value = 10; var json = JsonConvert.SerializeObject(example); The JSON I'd get in return would look like: { "Value": 10 } These libraries support a lot of types by default. We can go backwards from JSON back to C#. Suppose I saw JSON like this: { "examples": [ { "Value": 10 } ] } Think about it by reading from top to bottom. This is: An object with properties: "examples", an array of objects that have these properties: "Value", an integer I see two objects in the definitions, so I need to write two classes: // "an object with an 'examples' property" // Note the name DOES NOT MATTER, because JSON objects do not have type names. public class Examples { // "an array of objects" // Note I can use a capital letter even though the JSON used lowercase, the serializer // is smart enough to handle that. public Example[] Examples { get; set; } } // "an object with a 'Value' property" public class Example { public int Value { get; set; } } The important thing to note is the serializer is smart enough to see that since Examples has an array of Example, it should try to parse the "inner" objects to fit the Example class. My second example intentionally looks a lot like your JSON. You have an object with an "APInvoices" property that is an array of other objects. THOSE objects have many properties, including some like "Images" that are arrays of OTHER objects. To serialize/deserialize your JSON, you're going to need to write 7 or 8 total C# classes.
2 of 2
1
As u/Slypenslyde mentioned, List get serialized to a JSON array in both Newtonsoft.Json and System.Text.Json so may be easier to handle than an array in some situations. You can also use annotations to map a property in JSON to a C# compliant name. using System; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; public class Program { public static void Main() { var root = new Root(); int idCnt = 0; // *** ignore this block, just to populate some fake invoices *** for (int i = 0; i < 10; i++) { var invoice = new Invoice() { InvoiceNumber = $"INV{(i + 1).ToString().PadLeft(5, '0')}", VendorCode = $"V{((i % 2) + 1).ToString().PadLeft(5, '0')}", }; int lineCnt = ((i % 2) + 1) * 4; for (int j = 0; j < lineCnt; j++) { idCnt++; invoice.ApInvoiceDetails.Add(new InvoiceLine() { ItemCode = $"PRD{((idCnt % 3) + 1).ToString().PadLeft(5, '0')}", ItemDescription = $"Some product we sell {((idCnt % 3) + 1)}", Quantity = ((j % 4) + 1), Amount = ((j % 3) + 1) * 5 }); } root.ApInvoices.Add(invoice); } // *** end ignore *** // serialize to json string string json = JsonSerializer.Serialize(root); Console.WriteLine(json); // deserialize for json string var newRoot = JsonSerializer.Deserialize(json); Console.WriteLine($"First invoice no: {newRoot.ApInvoices[0].InvoiceNumber}"); } private class Root { [JsonPropertyName("APInvoices")] public List ApInvoices { get; set; } = new(); } private class Invoice { [JsonPropertyName("Vendor_Code")] public string VendorCode { get; set; } [JsonPropertyName("Invoice_Number")] public string InvoiceNumber { get; set; } [JsonPropertyName("APInvoiceDetails")] public List ApInvoiceDetails { get; set; } = new(); } private class InvoiceLine { [JsonPropertyName("Item_Code")] public string ItemCode { get; set; } [JsonPropertyName("Item_Description")] public string ItemDescription { get; set; } public decimal Quantity { get; set; } public decimal Amount { get; set; } } }
🌐
Micro Focus
microfocus.com › documentation › silk-performer › 205 › en › silkperformer-205-webhelp-en › GUID-0847DE13-2A2F-44F2-A6E7-214CD703BF84.html
JSON Array Structure
In contrast to regular arrays from the BDL, the elements of a JSON array can be of different data types. The following data types are allowed for JSON arrays: [ ] //Empty JSON array [ 0, 1, 2, 3, 4, 5] [ “StringValue”, 10, 20.13, true, null ] [ { “Name” : “Nested Object” }, [ 10, 20, true, 40, “Nested Array” ] ]
🌐
IBM
ibm.com › docs › en › datapower-gateway › 10.6.0
JSON examples
JSON objects and arrays can be transformed with transform actions. The following examples and the examples in the related topics, provide sample JSON objects and arrays and transformations of those objects and arrays. These examples demonstrate some JSON message processing that the DataPower ...
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
For example, you may represent a street address such as 1600 Pennsylvania Avenue NW as a 4-tuple of the form: ... To do this, we use the prefixItems keyword. prefixItems is an array, where each item is a schema that corresponds to each index of the document's array.
Top answer
1 of 7
2

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)
🌐
Javatpoint
javatpoint.com › json-array
JSON Array - javatpoint
JSON Array for beginners and professionals with examples of JSON with java, json array of string, json array of numbers, json array of booleans, json srray of objects, json multidimentional array. Learn JSON array example with object, array, schema, encode, decode, file, date etc.
🌐
UiPath Community
forum.uipath.com › help › studio
JSON Array with multiple json objects and json arrays - Studio - UiPath Community Forum
September 25, 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, ...
🌐
ReqBin
reqbin.com › json › uzykkick › json-array-example
What is JSON Array?
The following is an example of an array of JSON booleans: ... A JSON object is similar to a JavaScript object. We can also create a JSON array containing many objects, and then we can iterate over this array or use "[]" square brackets to get the desired object.
🌐
Gastonsanchez
gastonsanchez.com › intro2cwd › json.html
42 JSON Data | Introduction to Computing With Data
For example [1, 3, 3] or ["computing", "with", "data"], which can be a set of any of the data types listed above. We typically use arrays when we have a set of unnamed values, this is why some people refer to them as ordered unnamed arrays. The closest R object to a JSON array would be a vector:
🌐
CodeUtility
blog.codeutility.io › programming › how-to-use-arrays-in-json-with-examples-in-code-5eeef2665f
How to use Arrays in JSON (With Examples in Code) | CodeUtility
September 26, 2025 - This structure is both flexible ... objects (Python list of dicts) users = [ { "name": "Alice", "active": True }, { "name": "Bob", "active": False }, { "name": "Carol", "active": True } ] # 1....