How to restore original object/type from JSON?

前端 未结 6 1696
旧时难觅i
旧时难觅i 2020-12-05 19:38

Its easy to load JSON into an object in javascript using eval or JSON.parse.

But if you have a proper \"class\" like function, how do you get the JSON data into it?<

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 19:56

    I;m not too much into this, but aPerson.addAddress should not work, why not assigning into object directly ?

    aPerson.address.push(someAddress);
    alert(aPerson.address); // alert [object object]
    

提交回复
热议问题