Sunday, October 9, 2011

Winter 12 New Feature - JSON Support


Earlier I used an open source library called JSONObject to parse the json string. It works fine to parse the google json but in some case I was having the following error messaage while parsing the JSON string.

“FATAL_ERROR|superpat.JSONObject.JSONException: Expected a , or }”

You can find solutions of the following error here.

Now in winter 12 release, Salesforce is providing a native support for JSON parsing.

As per the winter 12 release notes -
JSON Support
JavaScript Object Notation (JSON) support has been added. Using JSON classes, you can now parse JSON content and
serialize Apex objects into the JSON format. The following classes have been added for JSON support:
• System.JSON: Contains methods for serializing Apex objects into JSON format and deserializing JSON content that
was serialized using the serialize method in this class.
• System.JSONGenerator: Contains methods used to serialize Apex objects into JSON content using the standard JSON
• System.JSONParser: Represents a parser for JSON-encoded content.

You can also find the another cool article on JSON parser here


No comments:

Post a Comment