JSON stands for JavaScript Object Notation. A JSON object is really a string that has yet to be turned into the object it represents.

To add a property to an existing object in JS you could do the following.

object["property"] = value;

or

object.property = value;

If you provide some extra info like exactly what you need to do in context you might get a more tailored answer.

Answer from Quintin Robinson on Stack Overflow
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-add-new-property-to-json-object-using-javascript.php
How to Add New Property to JSON Object Using JavaScript
// Store JSON string in a JS variable var json = '{"name": "Harry", "age": 18}'; // Converting JSON-encoded string to JS object var obj = JSON.parse(json); // Adding a new property using dot notation obj.gender = "Male"; // Adding another property using square bracket notation obj["country"] = "United States"; // Accessing individual value from JS object document.write(obj.name + "<br>"); // Prints: Harry document.write(obj.age + "<br>"); // Prints: 14 document.write(obj.gender + "<br>"); // Prints: Male document.write(obj.country + "<br>"); // Prints: United States // Converting JS object back to JSON string json = JSON.stringify(obj); document.write(json);
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-how-to-add-an-element-to-a-json-object
Adding Elements to a JSON Object in JavaScript - GeeksforGeeks
January 17, 2026 - JSON objects are mutable in JavaScript. New properties can be added dynamically. No special method is required. let jsonObject = { key1: 'value1', key2: 'value2' };
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-how-to-add-an-element-to-a-json-object
How to Add an Element to a JSON Object using JavaScript? | GeeksforGeeks
August 27, 2024 - In JavaScript to add an element to a JSON object by simply assigning a value to a new key.
🌐
ServiceNow Community
servicenow.com › community › developer-forum › add-values-to-json-object › m-p › 1972843
Solved: Add values to json object - ServiceNow Community
September 19, 2019 - You can add another set of values by pushing another object into that "records" array, i.e. gs.print("code: " + httpResponseStatus); gs.print("body: " + JSON.parse(response.getBody())); var b = JSON.parse(response.getBody()) var data = b.records; //Just an example, you could also push the details ...
🌐
Jsdiaries
jsdiaries.com › how to add an array element to json object in javascript.
How to add an array element to JSON object in JavaScript. | The JavaScript Diaries
From time to time we need to manipulate JSON data by adding new elements into it. A JSON object is typically more difficult to directly edit as its normally in a string format. So, how can you add an array element into a JSON Object in JavaScript? This is done by using the JavaScript native methods
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
How to add a key/value pair to an existing json file? - JavaScript - The freeCodeCamp Forum
September 8, 2023 - The Json file would look some like this: { “data”: [ { "id": "1700148573403304137", "text": "Hi ! " }, { "id": "1700147255322259501", "text": "Hello" } ] For the final I want to add something like: “te…
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-add-an-element-to-a-json-object-using-javascript
How to add an element to a JSON object using JavaScript?
February 16, 2023 - Bracket notation is useful when ... JSON object:"); console.log(jsonObject); console.log("\nAdding an element using bracket notation:"); jsonObject.members.viewers['userName3'] = 'userData3'; console.log("\nJSON object ...
🌐
Educative
educative.io › answers › how-to-add-data-to-a-json-file-in-javascript
How to add data to a JSON file in JavaScript
Let's run the following widget and update the record of the data.json file by adding some data to it. { "users": [ { "name": "John Doe", "email": "john.doe@example.com" }, { "name": "Jane Smith", "email": "jane.smith@example.com" }, { "name": "Bob Johnson", "email": "bob.johnson@example.com" } ] } ... Line 1: Import the fs module for reading and writing into the file. Line 4: Read data from the file using the readFileSync() method. Lines 11–14: Modify the JavaScript object by adding new data.
Find elsewhere
🌐
SitePoint
sitepoint.com › javascript
Adding items to a JSON object - JavaScript - SitePoint Forums | Web Development & Design Community
March 3, 2009 - Does anyone know the function for adding more items to an already declared JSON object · Not correct!! The line event[i] is wrong. When i send ‘events’ to console i get something this - iterating over a numer of variables and adding their values to the JSON object: · I reckon the object ...
🌐
Latenode
community.latenode.com › other questions › javascript
What is the method to insert a value in a JSON object array? - JavaScript - Latenode Official Community
November 3, 2024 - Here’s a simplified example: let data = [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' } ]; // Add 'age' property to each object for (let obj of data) { obj.age = 25; } console.log(data); This modifies the existing objects by adding an ‘age’ ...
🌐
Stack Overflow
stackoverflow.com › questions › 57959147 › add-items-to-json-object
javascript - Add items to JSON object - Stack Overflow
The objects must contain the structure and properties ("name" and "id" within a "data" sub-property) matching the JSON coming from the Promise, so that your loop code can process them. In the simplest case, it could be as straightforward as · x.done(function(data) { data.push({ "data": { "name": "light", "id": 1234 } }); data.push({ "data": { "name": "dark", "id": 5678 } }); for(var i in data) { var m = '<option value="' + data[i].data.id + '"' if (data[i].data.id == selected_val) { m += ' selected="selected"'; } m += '>' + data[i].data.name + '</option>'; $('#' + value_element_id).append(m); } });
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-add-new-attribute-to-json-object
JavaScript | Add new attribute to JSON object - GeeksforGeeks
June 25, 2021 - </title> </head> <body style="text-align:center;" id="body"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP" style="font-size: 16px; font-weight: bold;"> </p> <button onclick="gfg_Run()"> Click here </button> <p id="GFG_DOWN" style="color:green; font-size: 20px; font-weight: bold;"> </p> <script> var el_up = document.getElementById("GFG_UP"); var el_down = document.getElementById("GFG_DOWN"); var myObj = { 'prop_1': { 'prop_12': 'value_12' } }; el_up.innerHTML = JSON.stringify(myObj); function gfg_Run() { var key = "prop_11"; myObj.prop_1[key] = "value_11"; el_down.innerHTML = JSON.stringify(myObj); } </script> </body> </html> ... Example 2: This example adds a prop_11 attribute to the myObj with value value_11. ... <!DOCTYPE HTML> <html> <head> <title> JavaScript | Add new attribute to JSON object.
🌐
Quora
quora.com › How-do-you-add-elements-to-a-JSON-Array
How to add elements to a JSON Array - Quora
Answer (1 of 3): Here’s how you add elements to a JSON array—let’s break it down like you’re sitting around a table with a laptop, trying to figure this out. So, first off, JSON arrays are those square-bracket lists of stuff, right? Like `["apple", "banana"]`. To add something, you gotta think ab...
🌐
W3Schools
w3schools.com › js › js_json_objects.asp
JSON Object Literals
JS Examples JS HTML DOM JS HTML ... JS Interview Prep JS Bootcamp JS Certificate JS Reference ... JSON object literals are surrounded by curly braces {}....