So why don't you simply use a key-value literal?

var params = {
    'slide0001.html': 'Looking Ahead',
    'slide0002.html': 'Forecase',
    ...
};

return params['slide0001.html']; // returns: Looking Ahead
Answer from Crozin on Stack Overflow
🌐
W3Schools
w3schools.com › js › js_json_objects.asp
JSON Literals
JSON object literals contains key/value pairs.
🌐
Baeldung
baeldung.com › home › json › get a value by key in a jsonarray
Get a Value by Key in a JSONArray | Baeldung
January 8, 2024 - A JSONArray object is enclosed within square brackets [ ] whereas a JSONObject is enclosed within curly braces {}. For instance, let’s consider this JSON message: [ { "name": "John", "city": "chicago", "age": "22" }, { "name": "Gary", "city": "florida", "age": "35" }, { "name": "Selena", "city": "vegas", "age": "18" } ] Clearly, it’s an array of JSON objects. Each JSON object in this array represents our customer record having a name, age, and city as its attributes or keys...
🌐
Micro Focus
microfocus.com › documentation › silk-performer › 195 › en › silkperformer-195-webhelp-en › GUID-6AFC32B4-6D73-4FBA-AD36-E42261E2D77E.html
JSON Object Structure
A key-value pair consists of a key and a value, separated by a colon (:). The key is a string, which identifies the key-value pair. The value can be any of the following data types: { } //Empty JSON object { “StringProperty”: “StringValue”, “NumberProperty”: 10, “FloatProperty”: 20.13, “BooleanProperty”: true, “EmptyProperty”: null } { “NestedObjectProperty”: { “Name”: “Neste Object” }, “NestedArrayProperty”: [10,20,true,40] }
Find elsewhere
🌐
Mixu
book.mixu.net › node › ch5.html
5. Arrays, Objects, Functions and JSON - Mixu's Node book
You can use this to count the number ... is 2 console.log(keys, keys.length); An easy way to iterate through the keys is to use Object.keys() and then apply Array.forEach() on the array: var group = { 'Alice': { a: 'b', b: 'c' }, 'Bob': { a: 'd' }}; var people = Object.keys(group); ...
🌐
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.
🌐
Quora
quora.com › How-can-I-extract-and-change-key-JSON-Array-of-Objects-in-JavaScript
How to extract and change key JSON Array of Objects in JavaScript - Quora
Answer (1 of 3): Well here’s how to do it as requested: [code]// initial data var books = { "History": [ {"Number": "AD-3424"}, {"Number": "AD-3424"} ] }; // changing the array at books.History using Array.prototype.map books.History = books.History.map(function(book) { return {"...
🌐
LinkedIn
linkedin.com › pulse › json-array-objects-structure-vs-object-symbols-keys-specific-dastpak-mdp9f
JSON Array of Objects Structure vs JSON Object with Symbols as Keys Structure (Specific Conditions)
February 3, 2024 - Partial Updates: Leverage the structure's key-value pairs for efficient updates by directly accessing and modifying only the necessary items without iterating through the entire object. Memory Management: Be mindful of object size; larger objects can increase memory usage. Consider splitting massive datasets into smaller segments or using lazy loading techniques. ... In a React-based application, managing the state efficiently is crucial for a seamless user experience. The second JSON structure shines here by enabling instant access to any currency's details without iteration, making it especially suitable for real-time applications.
🌐
TutorialsPoint
tutorialspoint.com › from-json-object-to-an-array-in-javascript
From JSON object to an array in JavaScript
The Object.entries() method in JavaScript will return an array containing the enumerable properties [key, value pairs] in the JSON Object. By default, the internal enumerable value is true, as we assigned the properties of the object using a simple assignment, the ordering of properties in ...
🌐
cyberangles
cyberangles.org › blog › can-a-json-array-contain-objects-of-different-key-value-pairs
Can a JSON Array Contain Objects with Different Key/Value Pairs? Validity Explained — CyberAngles.org
Example of a valid JSON array with mixed primitive types: ... A JSON object is an unordered collection of key-value pairs, enclosed in curly braces ({}).
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)
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-json-array
What is JSON Array? - GeeksforGeeks
July 23, 2025 - Example: Here we assign a JSON Array of Objects to the key books in jsonObjectArray object.
🌐
Squarespace
developers.squarespace.com › what-is-json
What is JSON? — Squarespace Developers
Since each post in a blog can have more than one category, an array of multiple strings is returned. "foo" : { "bar" : "Hello", "baz" : [ "quuz", "norf" ] } An object is indicated by curly brackets. Everything inside of the curly brackets is part of the object. We already learned a value can be an object. So that means "foo" and the corresponding object are a key/value pair. ... The key/value pair "bar" : "Hello" is nested inside the key/value pair "foo" : { ... }. That's an example of a hierarchy in JSON data.