UiPath Activities

The UiPath Activities Guide

Create and Deserialize a JSON Array

The example below explains how to use activities such as Invoke Code and Deserialize Json Array to create a JSON array, deserialize it, and provide the list of extracted tokens. You can find these activities in the UiPath.Web.Activities package.

This is how the automation process can be built:

  1. Open Studio and create a new Process.
  2. Drag a Sequence container in the Workflow Designer.
    • Create the following variables:

Variable Name

Variable Type

Default Value

jsonAsString

String

jsonAsArray

JArray

  1. Add an Invoke Code activity inside the Sequence.
    • Click the Edit Code button and add the following code in the opened window:
obj.Add("Starcraft")
obj.Add("DOTA 2")
obj.Add("FarCry")
out = JsonConvert.SerializeObject(obj)
  • Once the code added, click the OK button.
  • Click the Edit Arguments button and add the following argument:

Argument

Direction

Type

Value

out

Out

String

jsonAsString

  • Once finished, select the OK button like in the below GIF:
  1. Add a Log Message activity below the Invoke Code activity.
    • Add the expression "JSON As String: "+jsonAsString in the Message field.
  2. Add a Deserialize Json Array activity below the Log Message activity.
    • Add the variable jsoAsString in the Json String field.
    • In the Properties panel, add the variable jsonAsArray in the JsonArray field.
  3. Add a For Each activity below the Deserialize Json Array activity.
    • Add the value token in the ForEach field.
    • Add the variable jsonAsArray in the VB expression field.
  4. Add a Log Message activity inside the Body of the For Each activity.
    • Add the expression token.ToString in the Message field.

This is how the workflow should look:

  1. Run the process. A JSON array is created, deserialized as a String and provided as a list of extracted tokens.

Updated 3 months ago


Create and Deserialize a JSON Array


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.