Is there any built-in activity/package that can be used to modify JSON

Hi, I need to do API calls to a software and update the fields using the JSON retrieved. I was looking on the UiPath Marketplace for any pre-built activity that can help us in editing/Modifying JSON.
Any help will be greatly appreciated!!
Thanks

2 Likes

Depends on what you mean by modifying

pre-built activity won’t be there just to directly edit/modify, i guess, as the json can be nested too. But you can script it if required.

Json can be converted and then edited. If you have only normal json to work with, then may be you can use de serialize json to convert and edit it.

If you can give idea about your data in json, that would help

UiPath.WebAPI.Activities

@chauhan.rachita30
Welcome Back to Community
deserialized the json that you received that convert into Jobject after that you can easliy modify json using Assign Activity

for Example
Jobject[“Key”]= “Change Value”

@chauhan.rachita30

Install UiPath.WebApi.Activities

Once installed, use HTTP request to call the API and use Deseralize JSON and you can use assign activity to edit

Check below for your reference

Hope this may help you

Thanks

Hi

Welcome back to UiPath forum

Hope the below nots would help you resolve this

  1. Firstly we have got already a readily available activity from UiPath for JSON which is UiPath.Web.Activities

For that go to DESIGN TAB → Manage Packages → In All Packages → search for the above package and install it

This activity will help you to interact with other applications through api and get the response in turn either in a xml or Json format

But if you want to do some changes to Json input received we can use just the invoke method

Let’s get into the practical implementation of this task:

Adding new key-value pair to JSON object:

Step1: The input JSON object that we are using for this example is shown below:

json data uipath

The input that we are using here is a JSON object and we will see how we can add a new key-value pair to this JSON object.

After processing the above JSON object we need to add a new key called Result.

Step2: Drag and Drop Invoke method activity from activities panel to designer panel as shown below:

add or update key value pair

Here:

  • TargetObject – Provide your JSON object variable value.
  • MethodName – As we are adding the new object to the existing object mention Add.

Let’s look at the parameters that are required for adding new object:

Here it requires two parameters and they are mentioned below:

  • First Parameter – Provide the object key name here.
  • Second Parameter – Provide the object value here.

In this example, we are adding a result key and value to the existing JSON object.

Step3 – After adding a new object to the existing JSON object that looks like below:

json data uipath

Updating the key value in JSON object:

In this example we will update the existing key value in the JSON object that is given above:

Step1; Drag and Drop assign activity from activities panel to designer panel as shown below:

add or update key value pair

Here:

  • To – Provide the key-value where you want to update the key value. (eg: JsonOutput(“Status”))
  • Value – Provide the value that needs to be updated.

Step2: The updated JSON object looks like below:

json data uipath

This is how we add or update the key-valuepair of JSON object using UiPath.

Hope this would help you resolve this

Eg ref : rpa learner’s

Cheers @chauhan.rachita30

1 Like