I create JSON
object as:
var myJsonObject = JSON.stringify(objectString)
How I can add another item into myJsonObject
??
To append json data/elements to a json file, read the file, parse the JSON, push the new result to the array, convert into a string, and save it.
' { } ' used for Object and ' [] ' is used for Array in json.
Looks like you're re-serializing the string rather than parsing it.
var myJsonObject = JSON.parse(objectString);
then you can add a new item by using
myJsonObject['newItemName'] = newValue;
Hope that's clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With