Activity Forums Salesforce® Discussions Json parsing in Salesforce

  • Kumar

    Member
    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?

    Thanks

  • Vikas Kumar

    Member
    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.
    Signature
    public static Object deserialize(String jsonString, System.Type apexType)
    Parameters
    jsonString
    Type: String
    The JSON content to deserialize.
    apexType
    Type: System.Type
    The Apex type of the object that this method creates after deserializing the JSON content.
    Return Value
    Type: Object
    Usage
    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