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
๐ŸŒ
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.
Discussions

api design - Representing a large list of complex objects in JSON - Software Engineering Stack Exchange
I am currently developing an API that returns JSON structures. One of the domain objects returned is a time series, which is a potentially large list (many thousands of elements) of complex objects... More on softwareengineering.stackexchange.com
๐ŸŒ softwareengineering.stackexchange.com
javascript - Array of JSON Objects - Stack Overflow
First of all, this is not JSON at all, you are just using Javascript objects. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to convert JSON object to JavaScript array? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I need to convert JSON object string to a JavaScript array. More on stackoverflow.com
๐ŸŒ stackoverflow.com
javascript - Convert array to JSON - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I have an Array var cars = [2,3,..] which holds a few integers. I've added a few values to the array, but I now need to send this array to a page via jQuery's .get method. How can I convert it to a JSON object for sending? ... Just double-checking: is the array you want to send to the page a JavaScript ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_json_objects.asp
JSON Object Literals
JSON cannot be an object. JSON is a string format. The data is only JSON when it is in a string format. When it is converted to a JavaScript variable, it becomes a JavaScript object.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ javascript โ€บ javascript json array of objects
How to Use Array of JSON Objects in JavaScript | Delft Stack
February 2, 2024 - We can create an array of JSON object either by assigning a JSON array to a variable or by dynamically adding values in an object array using the .push() operator or add an object at an index of the array using looping constructs like the for loop or while loop.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Learn_web_development โ€บ Core โ€บ Scripting โ€บ JSON
Working with JSON - Learn web development | MDN
The objects and arrays inside JSON need to further contain valid JSON data types. Strings must be enclosed in double quotes, not single quotes. Numbers must be written in decimal notation. Each property of an object must be in the form of "key": value. Property names must be string literals enclosed in double quotes. Special JavaScript syntax, such as methods, is not allowed because methods are functions, and functions are not valid JSON data types.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ JSON
JSON - JavaScript - MDN Web Docs
All properties and methods of JSON are static (just like the Math object). JSON is a syntax for serializing objects, arrays, numbers, strings, booleans, and null. It is based upon JavaScript syntax, but is distinct from JavaScript: most of JavaScript is not JSON.
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)
Find elsewhere
๐ŸŒ
Microverse
microverse.org โ€บ home โ€บ blog โ€บ how to loop through the array of json objects in javascript
How to Loop Through the Array of JSON Objects in JavaScript
September 29, 2022 - This tutorial will guide you on how to loop the array of JSON objects in JavaScript. Weโ€™ll explain the types of loops and how to use them.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_json.asp
JavaScript JSON
JSON makes it possible to store JavaScript objects as text. Text that defines an employees object with an array of 3 employee objects:
๐ŸŒ
PTC Community
community.ptc.com โ€บ t5 โ€บ ThingWorx-Developers โ€บ Search-through-array-of-JSON-objects โ€บ td-p โ€บ 859962
Solved: Search through array of JSON objects - PTC Community
March 7, 2023 - array.forEach(object => { // do your filtering here and array push here }); ... Services like find and filter work in ThingWorx, including ContentLoaderFunctions calls. This example works for me: let json = Resources["ContentLoaderFunctions"].GetJSON({ url: 'https://datausa.io/api/data?drilldowns=Nation&measures=Population' }); let result = { // JSON 'filtered': json.data.filter(row => (row['ID Year'] < 2015)) };
๐ŸŒ
JSONata
docs.jsonata.org โ€บ simple
Simple Queries ยท JSONata
Returns nothing (i.e. Javascript undefined) ... JSON arrays are used when an ordered collection of values is required. Each value in the array is associated with an index (position) rather than a name, so in order to address individual values in an array, extra syntax is required to specify ...
๐ŸŒ
RestfulAPI
restfulapi.net โ€บ home โ€บ json โ€บ json array
Multi-dimensional Array in JSON - REST API Tutorial
November 4, 2023 - It is known as an array of arrays or a multi-dimensional JSON array. var siteInfo = { "name" : "blogger", "users" : [ [ "admins", "1", "2" , "3"], [ "editors", "4", "5" , "6"], ] } A simple for loop to iterate over a multi-dimensional array in JSON.
๐ŸŒ
Mixu
book.mixu.net โ€บ node โ€บ ch5.html
5. Arrays, Objects, Functions and JSON - Mixu's Node book
JSON.parse() can be used to convert JSON data to a Javascript Object or Array: // returns an Object with two properties var obj = JSON.parse('{"hello": "world", "data": [ 1, 2, 3 ] }'); console.log(obj.data); ... The optional space parameter in JSON.stringify is particularly useful in producing ...
๐ŸŒ
Shapediver
shapediver.com โ€บ blog โ€บ json-objects-explained
JSON Objects Explained!
February 2, 2019 - An array is a collection or list of data. It is surrounded by square braces "[]" Typically, the JSON object will be created in a web application using Javascript. From there, the application can send the object to Grasshopper as a string (see next section). As a consequence, defining how the ...
๐ŸŒ
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.
๐ŸŒ
JSON
json.org
JSON
JSON is a text format that is ... Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. ... A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative ...