Reputation: 1057
I am trying to update an element of a JSON object to be an object inside that JSON object.
var storedObj = $storage("storedObj").get();
This returns something like this
storedObj = {
businessID: 1234,
businessName: Some Business,
businessAddress: null
}
I want to update businessAddress and re-save the object locally.
var bizAddress = {
city: "City Name",
state: "State Name",
Zip: "12345"
}
I tried this and it didn't work
storedObj.businessAddress = bizAddress;
$storage("storedObj").set(storedObj);
Ideally that would restore the entire object with the updated node.
Upvotes: 1
Views: 140
Reputation: 55750
It's may be becoz of
businessName: Some Business, // Supposed to be
businessName: 'Some Business', // Encased in Quotes
Upvotes: 1