开发者

eval json out of memory error

开发者 https://www.devze.com 2022-12-09 10:36 出处:网络
I\'m using JSON.parse function to load info about a cellset. I\'m testing how much data is possible to fetc开发者_运维问答h in one call.

I'm using JSON.parse function to load info about a cellset. I'm testing how much data is possible to fetc开发者_运维问答h in one call.

The eval function starts throwing "out of memory" between 1.3-1.4 million characters (65,000-70,000 cells) in the JSON string. Does anybody know of a workaround for this - perhaps a pure JSON parser, rather than eval?

Thanks, Nathan


I would recommend this one: http://json.org/js.html it's efficient.


You are definitely pushing way too much information to your client.

Possible workarounds:

  • Page your data and only load what is visible
  • Avoid JSON, use HTML and dump the HTML directly to the page with .innerHTML
  • Maybe use a native JSON parser like in Firefox and IE8 (possibly in other browsers, can't remember)
  • Try JSONP (including a script tag that calls a function with your data as an argument)
0

精彩评论

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