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
Discussions

How to make data in an array the keys of a JSON file?
I was processing some data and I have filtered the data to a point where I have stored the data which should be the keys of the JSON file I want to create into an array like this [ 'A', 'B', 'C', 'D', 'E' ] Now I want to set these array values as keys dynamically to create a JSON with other ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
February 14, 2023
How to access all similar keys in all objects in a JSON array of objects?
I want to get all the keys called “name” in all of the 3 objects here and print their values, How can I do that ? Expected output : “Leanne Graham”, “Ervin Howell”, “Marina Howell” [ { "id": 1, "… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
January 14, 2022
Converting object keys to an JSON array
Goal with this scenario. I’m working on getting a series of keys on a JSON webhook input into an email template. As some of the keys may be empty, I can’t just pass them to the MailGun email template or it will complain the value is missing. I was able to get it working with a custom JSON ... More on community.make.com
🌐 community.make.com
1
0
August 11, 2023
How to store key values of a JSON array of object in an array
You can iterate over an array using the map function which takes a callback, and return exactly which property you want from each user object inside the callback. You'll be left with an array of names. More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 - Micro Focus website
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.
🌐
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.
🌐
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)
🌐
DigitalOcean
digitalocean.com › community › tutorials › an-introduction-to-json
An Introduction to JSON | DigitalOcean
August 24, 2022 - The "websites" key and "social_media" key each use an array to nest information belonging to Sammy’s two website links and three social media profile links. You can identify that those are arrays because of the use of square brackets. Using nesting within your JSON format allows you to work with more complicated and hierarchical data.