Activity Forums Salesforce® Discussions How to convert Javascript objects into Salesforce JSON?

  • Nikita

    Member
    August 20, 2019 at 6:36 am

    You can use JSON.serialize() method .

    for example

    Account acc = new Account(Name = 'Account Name', Phone = '8888888888', Industry = 'Agriculture');
    //Code to convert Account to JSON string
    String str = JSON.serialize(acc);
    system.debug('Account JSON Data - ' + str);

  • Deepak

    Member
    August 20, 2019 at 12:32 pm

    JSON is to collect as JSON data from a web server as a file or HTTP request and convert the JSON data to a JavaScript, and then it avails the data in a web page.

    The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos