Activity Forums Salesforce® Discussions Json parsing in Salesforce

  • Kumar

    December 14, 2016 at 10:59 am

    Hi everyone,

    How can we parse a Json file to a specified stanadard or custom object in Salesforce?


  • Vikas Kumar

    January 9, 2017 at 12:23 pm

    Hi kumar,

    you can use json.deserialize() for converting json content into standard object or customobject

    deserialize(jsonString, apexType)
    Deserializes the specified JSON string into an Apex object of the specified type.
    public static Object deserialize(String jsonString, System.Type apexType)
    Type: String
    The JSON content to deserialize.
    Type: System.Type
    The Apex type of the object that this method creates after deserializing the JSON content.
    Return Value
    Type: Object
    If the JSON content contains attributes not present in the System.Type argument, such as a missing field or object, deserialization fails in some circumstances. When deserializing JSON content into a custom object or an sObject using Salesforce API version 34.0 or earlier, this method throws a runtime exception when passed extraneous attributes. When deserializing JSON content into an Apex class in any API version, or into an object in API version 35.0 or later, no exception is thrown. When no exception is thrown, this method ignores extraneous attributes and parses the rest of the JSON content.

Viewing 1 - 2 of 2 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos