How to pass json string in the main argument of the process?

How to pass the below value as an input to the arguments?

{
“FromandTo”:{
“Pending”:{
“Date”:”as”
}
}

In general we can pass it as

  • Serialized JSON String

OR

  • JObject

@Ragavi_Rajasekar

In UiPath Studio, go to the workflow where you want to pass this JSON structure as an input.

Open the Arguments panel (usually found at the bottom of the screen) by clicking on the “Arguments” tab.

Click on the “Add” button to create a new argument.

Set the direction to “In” or “In/Out” based on your requirements.

Set the Argument Type:

In the “Argument” properties, for the “Type” field, select JObject from the dropdown.

Pass the JSON Structure:
-When invoking this workflow or sequence, pass the JSON structure as a string.
-Before passing the JSON structure, you need to convert it to a JObject. You can do this using the Deserialize JSON activity. This activity will convert the JSON string into a JObject, which can be passed as an argument.

1 Like

Hi @Ragavi_Rajasekar

  1. Create an Argument: In your workflow, create an argument of type JObject to represent the JSON structure. You can do this by going to the Arguments pane in the Workflow Designer and creating a new argument.

  2. Pass the JSON Structure as Argument Value: When you invoke the workflow that requires this JSON structure, you can assign the JSON structure to the argument. Here’s how you can assign the JSON structure to the argument value:

   ' Create a JObject to represent the JSON structure
   Dim jsonStructure As JObject = New JObject(
       New JProperty("FromandTo",
           New JObject(
               New JProperty("Pending",
                   New JObject(
                       New JProperty("Date", "as")
                   )
               )
           )
       )
   )
   
   ' Pass the JSON structure as an argument
   yourWorkflowArgument = jsonStructure

Replace yourWorkflowArgument with the actual argument variable or expression used when invoking the workflow.

  1. Use the Argument in the Workflow: Inside the workflow where you need to work with this JSON structure, you can access the argument value and manipulate it as needed. For example, if you want to access the “Date” value:
   ' Access the "Date" value from the argument
   Dim dateValue As String = yourWorkflowArgument("FromandTo")("Pending")("Date").ToString()

This way, you create a JObject to represent the JSON structure and pass it as an argument to your workflow. Inside the workflow, you can access and manipulate the JSON structure using the argument value.

Hope it helps!!

Thank you ! It works

1 Like

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