Skip to main content
January 13, 2013
Question

JSON parse failing over certain data size

  • January 13, 2013
  • 1 reply
  • 582 views

Hi

I'm loading this test object from an external txt file into CS6 using JSON.parse:

{"TEST":[{"Key1":"Val1","Key2":"Val2","Key3":"Val3"},{"Key1":"Val1","Key2":"Val2","Key3":"Val3"}]}

It works fine, except if I have over about 2500 copies of {"Key1":"Val1","Key2":"Val2","Key3":"Val3"} in the TEST array, then Error #1132: Invalid JSON parse input is triggered.

Anyone know of a datasize limit when parsing JSON?

This topic has been closed for replies.

1 reply

sinious
Legend
January 13, 2013

Very large. As mentioned in your other thread, here's 2 million additions of your previous example.

import flash.utils.getTimer;

// start time

var startTime:int = getTimer();

// make ridiculos 1 MILLION length object

var str:String = '{"songs":[{"Title":"Bad Influence","Artist":"Pink","DiscID":"EMI8988"}';

for (var i:int = 0; i < 2000000; i++)

{

          str += ',{"Title":"Bad Influence","Artist":"Pink","DiscID":"EMI8988"}';

}

str += ']}';

var myData:Object = JSON.parse(str);

trace(myData.songs[1999999].Title);

trace("Total time: " + (getTimer() - startTime) + "ms");

Trace:

Bad Influence

Total time: 13680ms

Anything even nearing 1 million should be using a database, and a good database, on a server, let alone the 2 million tested on a slow old laptop with 4GB RAM.