How to convert Jason into input text box and also pass variable into it

How to convert Jason into input text box and also pass variable into it.

Sample
{
“BusinessDate”: “2024-06-24”,
“ValuationDate”: “2024-06-24”,
“batchName”: "“non-cleared”
}

Date is variable here.

@sureshs15,

Kindly elaborate more on what you are trying to automate here.

Thanks,
Ashok :slight_smile:

I am trying to automate one of batch processing, I need to pass this input on one of swagger endpoint input. this is Jason type input.

one of many options:

create a dictionary of String, Object
populate it as needed
produce JSON String by
NewtonSoft.Json.JsonConvert.SerializeObject(yourDictVar)

@sureshs15,

Try the solution by PPR.

Can you provide more details

when working with dictionaries is new have a look here:

Hi @sureshs15 ,

For this Sample you have provided , one of the approach for the solution is to
1. Create a JSON Body with placeholder values

2. Take input from users or some source, i have used Assign activity to load the variables
image

3. Replace the JSON Body you created in step 1 with the variable values

And TADAAA!

You can then go ahead and serialize it or something according to your use case

Attaching the workflow I created for your reference
DynamicJSON.zip (2.9 KB)

Bonus Point: You can keep the Placeholder Json Body in a text file and read and replace it with values in UiPath

Hope this helps you out

It would be much simpler to use String.Format:

jsonString:

{
"BusinessDate": "{0}",
"ValuationDate"”: "{1}",
"batchName": "{2}"
}

String.Format(jsonString,“2024-06-24”,“2024-06-24”,“non-cleared”)

If you need to pass it as JSON, which is usually how it works, then you don’t need to do any conversion.

Thanks , this format is worked.