user1572796
user1572796

Reputation: 1057

Updating json element to json object

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

Answers (1)

Sushanth --
Sushanth --

Reputation: 55750

It's may be becoz of

businessName: Some Business,   //   Supposed to be

businessName: 'Some Business',     // Encased in Quotes

WORKING HERE

Upvotes: 1

Related Questions