Activity Forums Salesforce® Discussions How JSON is converted into Apex class in Salesforce?

  • How JSON is converted into Apex class in Salesforce?

    Posted by Aditya on November 12, 2020 at 2:51 pm

    How JSON is converted into Apex class in Salesforce?

    Shweta replied 4 years ago 2 Members · 1 Reply
  • 1 Reply
  • Shweta

    Member
    November 12, 2020 at 2:57 pm

    You can create a wrapper with a list of objects like below and deserialize JSON to the wrapper.
    Example:
    Public class JSONtoApexClasses{
    Public List<JSONtoApexClass> tickets {get; set;}
    public class JSONtoApexClass{
    public String SUMMARY;
    public String CUSTOMERUSEREMAIL;
    }
    public static JSONtoApexClasses parse(String json) {
    return (JSONtoApexClasses) System.JSON.deserialize(json, JSONtoApexClasses.class);
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos