Bug in JSON parsing.. ?
-
absolutelyfreeweb last edited by
For an add-on, I'm trying to use JSON.parse() and JSON.Stringify(). Here is my code:
alert(jsonStr); var jsonData = JSON.parse(jsonStr); var str = JSON.stringify(jsonData); alert(str);
elements existing in jsonSTr are missing in str.
Here is jsonStr:
{
"favorite": {
"name": "Test Page",
"url": "www.test.com"
},
"folder": {
"name": "A Category",
"subfavorite": [{
"name": "Another Page",
"url": "www.test.com"
}, {
"name": "3rd Page",
"url": "www.test.com"
}]
},
"favorite": {
"name": "4th Page",
"url": "www.tomorrow.com"
}
}in str, the first favorite is completly missing !! opera 38
-
absolutelyfreeweb last edited by
bug reported it at chromium:
https://bugs.chromium.org/p/chromium/issues/detail?id=626949
-
absolutelyfreeweb last edited by
It should either
- throw a parse error if the syntax is not valid
or if it is valid, not silently omit nodes but
- return back all nodes in correct order.
-
absolutelyfreeweb last edited by
I have not looked it up in the RFCs but I think the second one is the correct way ( i.e. the syntax is valid ). A "duplicate key" is more like a limitation of the implementation and would not help me.