简体   繁体   中英

Parsing very large JSON strings in IE causing problems

I'm parsing a 2MB JSON string in IE8. The JSON.Parse line is taking a little while to return and IE8 shows a message asking the user if they want to abort the script.

Is there any way I can suppress this message? (or somehow speed up JSON.Parse)

I know about Microsoft KB175500 , however this is not suitable as my target users will not have administrator access to make the registry modifications on their SOE machines.

I had this same question. Apparently there is no way to suppress the message, but there are tricks to make IE think it's still working by using an asynchronous iteration pattern (dead link, view comments below).

This comes from an answer to one of my questions: loop is too slow for IE7/8

If the browser is unhappy with how long the JSON parser is taking, there are only four choices here I know of:

  1. Get a faster JSON parser that doesn't take so long.
  2. Break up your JSON data into smaller pieces so you are only parsing smaller pieces at once.
  3. Modify a JSON parser to work in chunks so it can parse part of the data in one chunk, then on a short timeout, parse the next chunk, etc... This will prevent the browser prompt, but is probably a lot of work to write/modify a JSON parser that works this way.
  4. If you can be sure the content is safe, then you could see if using eval instead of a JSON parser works around the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM