开发者

null values appearing in stringified js object (using json2.js and FF)

i have a js object a which contains several other objects within it (say b, c, ..., z). suppose before serializing it through json2, i delete objects b and c from my objects using delete. checking in firebug reveals that the objects b and c and the indexes b and c was removed. however, checking the serialized json string shows nulls where the d开发者_运维问答eleted objects were. i used the following code to generate the json string.

var json_data = JSON.stringify(template, null, 2);

am i missing something in the function call? or is there a bug when used with FF?


Maybe I didn't understand your question right, but I couldn't reproduce the problem in either chrome or firefox (4)

var obj = {p1: 'test1', p2: 'test2'};
console.log(obj);
delete obj.p1;
console.log(obj);
JSON.stringify(obj);

Object { p1="test1", p2="test2"}

Object { p2="test2"}

"{"p2":"test2"}"

Do you have an exemple of your problem ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜