I have a JSON string in which I have converted them into an object:
= Eval ("(" + jsonString + ")");
I can use all bits and can display them with no problem. The question is how do I add to the object
For example:
data.car [0] .name = "civic"; & Lt; Br> Data.car [1] .name = "s2000";
So, if I have an input box to add a new car, how do I add it to the car array?
Cheers
Using your example above, something like this:
data.car [0] = {name: "citizen"}; Data.car [1] = {Name: "s2000"};
This array element will provide a new object, with a property named 'name'. Warning, for a little more code reuse:
function car (name) {this.name = name} data.car [0] = new car ("citizen"); Data.car [1] = New Car ("s2000");
Comments
Post a Comment