admin管理员组文章数量:1410674
I am going to create a 1-D JSON array, I just want to be sure about it's scalability. Is there any upper limit on number of key:Value pairs that could be present in a JSON?
I am going to create a 1-D JSON array, I just want to be sure about it's scalability. Is there any upper limit on number of key:Value pairs that could be present in a JSON?
Share Improve this question asked Jan 19, 2016 at 11:13 Rishi PrakashRishi Prakash 1,8092 gold badges18 silver badges38 bronze badges 3-
6
new Array(1<<31-1)
yieldsArray[1073741824]
,new Array(1<<31)
throwsUncaught RangeError: Invalid array length
so... I guess that's your answer? – Niet the Dark Absol Commented Jan 19, 2016 at 11:16 - So as intrinsically JSON is also an array, whatever be the upper limit of Array will also be of JSON? – Rishi Prakash Commented Jan 19, 2016 at 11:33
- 1 Not necessarely: The limitation es from the array implementation in JavaScript (and the index used being an integer). So I guess it's up to the language/platform that you're using. But taken that JSON is being used as data exchange format you need to make sure that all sides can handle this amount of data within its own platform/language restrictions. – rdoubleui Commented Jan 19, 2016 at 11:40
1 Answer
Reset to default 8JSON is just a textual representation of JS objects so the only limit is the memory storage capacity that holds it.
For actual Javascript Arrays it depends on the implementation by the software, but per the spec:
http://www.ecma-international/ecma-262/5.1/#sec-15.4
Every Array object has a length property whose value is always a nonnegative integer less than 2^32
So the limit is (2^32)-1 or 4294967295 if adhering to the spec.
try {
new Array(4294967295);
} catch(e){
alert("Should be fine and not see this");
}
try {
new Array(4294967296);
} catch(e){
alert(e.name);
}
本文标签: Do we have an upper limit for number of keys in a JSON array in javascriptStack Overflow
版权声明:本文标题:Do we have an upper limit for number of keys in a JSON array in javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744986449a2636120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论