将json元素更新为json对象

时间:2012-09-28 00:53:03

标签: json local-storage

我正在尝试将JSON对象的元素更新为该JSON对象中的对象。

var storedObj = $storage("storedObj").get();

返回类似这样的内容

storedObj = {
    businessID: 1234,
    businessName: Some Business,
    businessAddress: null
}

我想更新businessAddress并在本地重新保存对象。

var bizAddress = {
    city: "City Name",
    state: "State Name",
    Zip: "12345"
}

我尝试了这个并且没有用

storedObj.businessAddress = bizAddress;

$storage("storedObj").set(storedObj);

理想情况下,这将使用更新的节点恢复整个对象。

1 个答案:

答案 0 :(得分:1)

可能是

的becoz
businessName: Some Business,   //   Supposed to be

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

WORKING HERE