Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JSON parse failing over certain data size

Guest
Jan 13, 2013 Jan 13, 2013

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?

TOPICS
ActionScript
559
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 13, 2013 Jan 13, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines