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
🌐
PTC Community
community.ptc.com › t5 › ThingWorx-Developers › Working-with-JSON-and-Arrays › td-p › 836109
Solved: Working with JSON and Arrays - PTC Community
November 9, 2022 - To me "Input" and "localJSON" should be the exact same type, both JSON objects with an array called "PlatformData". But it is only possibly to use .push() on one of the arrays, on the one variable declared in the code.
Discussions

Create JSON with Arrays of different types?
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. More on reddit.com
🌐 r/csharp
7
2
October 13, 2022
api design - Representing a large list of complex objects in JSON - Software Engineering Stack Exchange
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. ... A list of objects is easier to work with. You can use append, map, filter... All the nice things JS Arrays ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
June 14, 2021
Convert JSON file to Typescript Array of Objects

The interface has an iD field and the json has a date field. They need to be the same types. You also might need to use JSON.parse(stringValue) depending on how you are getting the JSON data.

More on reddit.com
🌐 r/Angular2
7
3
August 3, 2018
How to access nested array of objects from json server?

I’m not sure I understand your problem correctly.. but from what I understand, you need to change your server to return the values you want for a given route (url). For instance you could have a route like /starttime and your server handles this route by returning only the start time.

Otherwise, you need to handle this on the frontend. You make your call, get the JSON data. And then pull out starttime from the data:

  1. You fetch

  2. You parse the JSON

  3. You access the starttime value

Edit: look into the .find() function in javascript. That’s what you’ll need if you can’t modify the backend

Edit2: DM if you need more help :)

More on reddit.com
🌐 r/react
4
1
June 30, 2021
🌐
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.
🌐
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.
🌐
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” ] ]
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
Tuple validation is useful when the array is a collection of items where each has a different schema and the ordinal index of each item is meaningful. For example, you may represent a street address such as 1600 Pennsylvania Avenue NW as a 4-tuple of the form:
Find elsewhere
🌐
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; } } }
🌐
TutorialsPoint
tutorialspoint.com › how-to-write-create-a-json-array-using-java
How to Write/create a JSON array using Java?
import java.io.FileWriter; import java.io.IOException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class WritingJSONArray { public static void main(String args[]) { //Creating a JSONObject object JSONObject jsonObject = new JSONObject(); //Inserting key-value ...
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)
🌐
Udemy
blog.udemy.com › home › json array: passing array objects in your web apps
JSON Array: Passing Array Objects in Your Web Apps - Udemy Blog
June 13, 2014 - Notice the above code is much more ... previous examples. The above code is an array of customers. The advantage between this code and the previous object code is that you can loop through the above array more easily, and you have a name for your array. The name makes it easier to identify what is packaged in your JSON ...
🌐
Cswr
cswr.github.io › JsonSchema › spec › arrays
Arrays - JSON Schema
In this case, we are asking that the first element must be a string, the second one an integer and the third one a boolean. For example, this array validates against the schema ... Note that the default behaviour of JSON Schema allows us to have fewer items, as long as the corresponding (sub)schemas are satisfied.
🌐
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.
🌐
W3Schools
w3schools.com › js › js_json.asp
W3Schools.com
When storing data, the data has to be a certain format, and regardless of where you choose to store it, text is always one of the legal formats. JSON makes it possible to store JavaScript objects as text. Text that defines an employees object with an array of 3 employee objects:
🌐
React
react.dev › learn › rendering-lists
Rendering Lists – React
How to move data out of components and into data structures like arrays and objects. How to generate sets of similar components with JavaScript’s map(). How to create arrays of filtered items with JavaScript’s filter(). Why and how to set key on each component in a collection so React can keep track of each of them even if their position or data changes. 1. Splitting a list in two 2. Nested lists in one component 3. Extracting a list item component 4. List with a separator · This example shows a list of all people.
🌐
JSON Diff
jsondiff.com
JSON Diff - The semantic JSON compare tool
Validate, format, and compare two JSON documents. See the differences between the objects instead of just the new lines and mixed up properties.
🌐
IETF
datatracker.ietf.org › doc › html › rfc7519
RFC 7519 - JSON Web Token (JWT)
The octets representing the UTF-8 representation of the JOSE Header in this example (using JSON array notation) are: [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] ...
🌐
Python
docs.python.org › 3 › library › pickle.html
pickle — Python object serialization
2 weeks ago - Source code: Lib/pickle.py The pickle module implements binary protocols for serializing and de-serializing a Python object structure. “Pickling” is the process whereby a Python object hierarchy is...
🌐
Google AI
ai.google.dev › gemini api › structured outputs
Structured outputs | Gemini API | Google AI for Developers
January 12, 2026 - This example demonstrates how to extract structured data from text using basic JSON Schema types like object, array, string, and integer. from google import genai from pydantic import BaseModel, Field from typing import List, Optional class Ingredient(BaseModel): name: str = Field(description="Name of the ingredient.") quantity: str = Field(description="Quantity of the ingredient, including units.") class Recipe(BaseModel): recipe_name: str = Field(description="The name of the recipe.") prep_time_minutes: Optional[int] = Field(description="Optional time in minutes to prepare the recipe.") ingredients: List[Ingredient] instructions: List[str] client = genai.Client() prompt = """ Please extract the recipe from the following text.