Json parsing using Workbench
Tags: salesforce, beginners, productivity, tutorial
Published: 2019-11-26 11:03:36

---
title: Json parsing using Workbench
published: true
date: 2019-04-30 09:40:47 UTC
tags: #Salesforce, #Beginners,#productivity, #tutorial
canonical_url: https://www.girikon.com/blog/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](https://www.girikon.com.au/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](https://www.girikon.com/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](https://workbench.developerforce.com/login.php?startUrl=%2Fquery.php)**.At this point login with your Salesforce account.

[![workbench](https://www.girikon.com/wp-content/uploads/2019/04/workbench.png)](https://www.girikon.com/wp-content/uploads/2019/04/workbench.png)

2. Go to **Utilities** -> and select **Rest Explorer**

3. Select the **Http Method** as **POST**.

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

[![json](https://www.girikon.com/wp-content/uploads/2019/04/json.png)](https://www.girikon.com/wp-content/uploads/2019/04/json.png)

5. Set the URL according to Mapping URL and Method

[![json](https://www.girikon.com/wp-content/uploads/2019/04/code.png)](https://www.girikon.com/wp-content/uploads/2019/04/code.png)

6. Provide the JSON Data in Request body.

[![json](https://www.girikon.com/wp-content/uploads/2019/04/coding.png)](https://www.girikon.com/wp-content/uploads/2019/04/coding.png)

And, check the content type from headers.

[![json code](https://www.girikon.com/wp-content/uploads/2019/04/json-code.png)](https://www.girikon.com/wp-content/uploads/2019/04/json-code.png)

**OUTPUT from the Rest Method will be as follows:**

[![json output](https://www.girikon.com/wp-content/uploads/2019/04/json-output.png)](https://www.girikon.com/wp-content/uploads/2019/04/json-output.png)

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

[![output](https://www.girikon.com/wp-content/uploads/2019/04/output.png)](https://www.girikon.com/wp-content/uploads/2019/04/output.png)

**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](https://www.girikon.com/wp-content/uploads/2019/04/json-data.png)](https://www.girikon.com/wp-content/uploads/2019/04/json-data.png)

3. Provide the JSON Data in Request body.

For example:

[![request body](https://www.girikon.com/wp-content/uploads/2019/04/request-body.png)](https://www.girikon.com/wp-content/uploads/2019/04/request-body.png)

This will create an account sObject in your Org.

**OUTPUT:**

[![output](https://www.girikon.com/wp-content/uploads/2019/04/output-new.png)](https://www.girikon.com/wp-content/uploads/2019/04/output-new.png)

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

[![account](https://www.girikon.com/wp-content/uploads/2019/04/new-account.png)](https://www.girikon.com/wp-content/uploads/2019/04/new-account.png)


The post [Json parsing using Workbench](https://www.girikon.com/blog/json-parsing-using-workbench/) appeared first on [Salesforce Consulting Company | United States | Phoenix, Arizona](https://www.girikon.com/).