I have an excel sheet which has data and I need UIPath to pass few selective data into a JSON file. How is this possible?
I assume you know how to read your data from Excel.
1/ Make sure you import Newtonsoft.Json namespace
2/ Create variable of type Newtonsoft.Json.Linq.JObject, e.g. objJson
3/ Initialize the variable using Assign activity
objJson = new JObject
4/ Add values from your Excel to the Json variable using Assign activity
objJson(“attribute1”) = “Attribute1Value”
objJson(“attribute2”) = “Attribute2Value”
5/ Save Json variable to file using “Write text file” activity
Resulting file:
{
“attribute1”: “Attribute1Value”,
“attribute2”: “Attribute2Value”
}
Cheers
Thanks, this worked.
There is another possibility for json like this which needs to be constructed from the excel data
{
“id”: “someid”,
“number”:“somenumber”,
“data”:{
“bio”:“somebio”,
“operation”:“someoperation”
}
}
Any suggestions on how I could get this done using the data from excel please?
Like this:
objJson = New JObject(
New JProperty("id","someid"),
New JProperty("number","somenumber"),
New JProperty("data",
New JObject(
New JProperty("bio","somebio"),
New JProperty("operation","someoperation")
)
)
)
For more info look here:
Thanks mate!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.