Write a New JSON file

Hi,

I have a requirement where I need to new create a JSON file in a folder and update the file with Asset Name (Key) and Asset value I get from Orchestrator. Once the Process is completed, I need to delete this JSON file.

Can someone help me out with this.

@besakkiappan46

  1. Create a JSON File: Use the “Write Text File” activity to create a JSON file in a specified folder. You can use a template JSON structure or create an empty JSON object initially.
  2. Read Asset Values from Orchestrator: Use the Orchestrator HTTP activities or Orchestrator API to retrieve the Asset values you need. Store these values in variables.
  3. Update JSON File: To update the JSON file with the Asset Name (Key) and Asset value, you’ll need to read the JSON content, modify it, and then write it back to the file. Here’s a general outline of the steps involved:a. Read the JSON content from the file using the “Read Text File” activity. b. Deserialize the JSON content into a JObject using the Newtonsoft.Json library (you may need to install this package in UiPath). c. Add or update the Asset Name (Key) and Asset value in the JObject. d. Serialize the modified JObject back to JSON format. e. Write the updated JSON content back to the file using the “Write Text File” activity.
  4. Delete JSON File: After your process is completed, use the “Delete File” activity to remove the JSON file from the folder.

Hope it helps!!

1 Like

Hi @besakkiappan46

  1. Create a JSON File: Use the “Create File” activity to create a JSON file in a folder of your choice. Set the file path and name with the “.json” extension. This will create an empty JSON file that you will update later.
  2. Get Asset Values from Orchestrator: Use the “Get Asset” activity to retrieve the asset value from Orchestrator. Make sure you have connected your UiPath project to Orchestrator and have the necessary credentials to access the asset.
  3. Write Asset Values to the JSON File: Use the “Write Text File” activity to write the asset values to the JSON file you created earlier. You can format the JSON data as required using dynamic content or a custom JSON template.
  4. Delete the JSON File: Once the process is completed and you no longer need the JSON file, use the “Delete File” activity to delete the file from the folder.
1 Like

bouncing back between a Dictionary and JSON with

  • Deserialize JSON
  • Serialize JSON

maybe will do it for you

1 Like

Thanks Everyone. I have put all the contents as an Asset. I got the asset in the process, Used Write Text File to write the values I got. Used them in my process and deleted it using Delete File.

@besakkiappan46

if you find the solution please do mark as solution to close the loop.

regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.