DEV Community

girikon
girikon

Posted on • Originally published at girikon.com on

Json parsing using Workbench

Parsing JSON data from Workbench

Why do we always start a question with “why”? The first question that comes to our mind is “Why we are using Workbench for JSON parsing?”

As a Salesforce Consultant I would also follow up similarly with a few other questions such as “Is it the simplest method of Parsing JSON data?”, and “are there other ways in which we can parse JSON data in workbench”. Over the last 4 years with Girikon in the Salesforce Consulting Services team I will try and answer the questions above through an understanding of the given methods below:

METHOD 1: JSON PARSING THROUGH WORKBENCH VIA SERVER

The JSON file is developed as separate code and therefore the most efficient way to check the dynamic project is through the Workbench JSON data parsing method which will benefit the developer by bypassing the rest of the code meaning there is no chance of changing existing code and messing it up. Using Workbench JSON data parsing method also provides the additional benefits such as time saving which translates to increased efficiencies, less complexity and reduced vulnerability to the written code.

Follow the below steps for using Rest Method through workbench:

  1. Before you start it is important to set up an account in Workbench.

https://workbench.developerforce.com/login.php?startUrl=%2Fquery.php.At this point login with your Salesforce account.

workbench

  1. Go to Utilities -> and select Rest Explorer

  2. Select the Http Method as POST.

  3. Create an Apex class, for mapping the data to be Posted.

json

  1. Set the URL according to Mapping URL and Method

json

  1. Provide the JSON Data in Request body.

json

And, check the content type from headers.

json code

OUTPUT from the Rest Method will be as follows:

json output

and a new account record will be created in Account sObject .

output

METHOD 2: JSON DATA PARSING THROUGH WORKBENCH TO SOBJECTS

  1. Go to workbench -> Rest Explorer -> HTTP Method POST

  2. Now, set the path of the sObject you want as we have used sObject Account to Parse the JSON data

.json data

  1. Provide the JSON Data in Request body.

For example:

request body

This will create an account sObject in your Org.

OUTPUT:

output

and a new account record will be created in Account sObject.

account

The post Json parsing using Workbench appeared first on Salesforce Consulting Company | United States | Phoenix, Arizona.

Top comments (0)