【发布时间】:2014-02-02 13:30:12
【问题描述】:
我有这个结构的一个原型:
function MyObj() { }
MyObj.prototype = {
prop1: {
prop11: null,
prop12: null,
prop13: null,
},
prop2: {
prop21: null,
prop22: null,
prop23: null,
},
prop3: {
prop31: [],
prop32: '',
prop34: [],
},
prop4: {
prop41: null,
},
}
当我拨打JSON.stringify(myObjInstance) 时,我得到{},为什么?
【问题讨论】:
-
类似于stackoverflow.com/questions/12369543/…。您可以编写自定义
toJSON方法来避免这种情况。
标签: javascript json