If I have a JSON structure that looks something like this:
var user = {
map: {
width: 785,
height: 791
},
image: {
name: "image.png",
size: {width:32}
},
properties:[{
firstName: "Bob",
lastName: "Jones",
}]
};
How would I change (after creation) the value of the firstName property to “Jane”?
I am fairly new to JSON, and I’m just trying to figure out how to make this one change for now. Any help would be greatly appreciated.
Well, one reason for your confusion might be that this is not JSON at all. JSON is a text format used for serialising objects. This is just a literal object in Javascript.
To change the
firstNameproperty, you would access the first item in thepropertiesarray in theuserobject: