Activity Forums Salesforce® Discussions How to convert object to Json string in apex of Salesforce?

  • Kirandeep

    Member
    July 24, 2020 at 5:18 PM

    <pre title=””>Account acc = new Account(Name = ‘Account Name’, Phone = ‘8888888888’, Industry = ‘Agriculture’);
    //Code to convert Account to JSON string
    String str = JSON.serialize(acc);

  • [adinserter block='9']
  • Ashish

    Member
    July 25, 2020 at 5:14 AM

    Hey Aditya,
    Always check the official Apex developer guide in the first place, so you would get to know all things related to your question.
    https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm
    Here, you can check all methods of JSON class.

Log In to reply.