I am new to JSON and Here is my First JSON Object
var First = {
"a" : [{}]
};
I want to add the below object to “a” in “First”
var a = {"1":"One","2":"Two"};
I have tried below code
First.a[First.a.length-1] = a;
It is not working.I assume that there are some syntax mistakes in this. Please help me on this.
it you want to add it, you’re looking for
First.a.push(a)if you want to replace the last element:
if you want to append a to the last element:
or
if it’s none of these, please add the expected json in your question.