YashMittal05 / apex-library

Automatically exported from code.google.com/p/apex-library
0 stars 0 forks source link

JSON Parsers Throw Syntax Error #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The leading JSON Parser from Douglas Crockford 
(http://www.json.org/json2.js) and www.JSONLint.com apparently don't like 
the LValue keys to be without quotes.

Example: {foo: "bar"} should be {"foo": "bar"}

JSONObject.valueToString() doesn't emit quotes around keys. I've updated 
this method as follows to appease various JSON parsers...

public String valueToString() {
    string ret = '{';
    for ( string key: this.keys() ) { 
        ret += '"' + key + '": ' + 
this.getvalue(key).valueToString() + ',';
    }
    return ret.substring(0,ret.length()-1) + '}';
}

Original issue reported on code.google.com by mle...@gmail.com on 26 Mar 2010 at 1:21

GoogleCodeExporter commented 8 years ago
Changes checked-in March 25, 2010

Original comment by mle...@gmail.com on 26 Mar 2010 at 7:48