Hi, I would like to use Prototype's isJSON() to test for valid JSON
strings before eval'ing them. For strings around 244kb in size, this
is tremendously slow, around 200 seconds, shooting the process' CPU
utilization right up to 97% from 0.1% for the same duration.

The method looks like this:

isJSON: function() {
  var str = this;
  if (str.blank()) return false;
  str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
  return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
}

Your help would be much appreciated. Thanks in advance!
_______________________________________________
dev-tech-js-engine-rhino mailing list
dev-tech-js-engine-rhino@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to