douglascrockford / JSON-js

JSON in JavaScript
http://www.JSON.org/
8.7k stars 4.59k forks source link

json2.js throwing SyntaxError: JSON.parse while parsing !! #73

Closed uacharya closed 8 years ago

uacharya commented 8 years ago

I have a json object that is stringified and this is how it looks like (small part of the object):

[{"name":"ArrayInterpolator","size":1983,"parent":{"$ref":"$[\"children\"][11]"},"depth":3,"value":1983,"x":0.8257659609894478,"y":204,"dx":0.0130312504527497,"dy":68,"sum":1983,"key":"animate.interpolate.ArrayInterpolator","fill":{"l":86.88283782905027,"a":-54.085032053595995,"b":48.724495533444134,"brighter":function (n){return new hn(Math.min(100,this.l+Ga(arguments.length?n:1)),this.a,this.b)},"darker":function (n){return new hn(Math.max(0,this.l-Ga(arguments.length?n:1)),this.a,this.b)},"rgb":function (){return gn(this.l,this.a,this.b)},"toString":function (){return this.rgb()+""}}}

The problem is that this object is parsed fine if the "brighter", "darker","rgb","toString" properties are removed but when they are added it generates SyntaxError: JSON.parse. I need these properties to run my d3 page accurately. Is there any way this js can be modified to parse these properties as well ?

douglascrockford commented 8 years ago

JSON is a formally defined data interchange format.