Hi,
I am trying to download Json file with HTTP request. The next step for me is extracting data from the Json file to Excel data table. Please advice how could I extract/convert it into Excel format.
Thank you.
Hi,
I am trying to download Json file with HTTP request. The next step for me is extracting data from the Json file to Excel data table. Please advice how could I extract/convert it into Excel format.
Thank you.
Can we get a look at required Jason file? Does it have a fixed format ?
Hi @RishiVC1,
Sorry that I couldnât upload the Json file as it is confidential. However, I could provide you some details on how does it looks like.
Yes, it has a fixed format. The format would be âdataâ:[{âidâ: 0111, ânameâ: xxx:, âstatusâ: âCâ,âaddressâ:âxxxâ:{âidâ: 0112, ânameâ: xxx:, âstatusâ: âCâ,âaddressâ:âxxxâ:{âidâ: 0113, ânameâ: xxx:, âstatusâ: âCâ,âaddressâ:âxxxâ}]}.
And I wanted to convert and sort the data into excel with the header, Id, name, status and address.
Thank you.
hi @leewe01
If You using HTTP Request and got your variable in output you need to deserialize jason. In assign window You can ask about needed value for example: variablefromdeserializetion(âvalueâ)(0)(ânameofyourcolumnâ).tostring assigned value you need to put in to the predefined table using add data row. Last thing is write ready table to excel file if You need sort it you can use âsort tableâ
Regards
@fudi5
Hi @leewe01
You provided incorrect json string, Iâm going to assume you meant:
{"data":[{"id": 0111, "name": "xxx", "status": "C","address":"xxx"},{"id": 0112, "name": "xxx", "status": "C","address":"xxx"},{"id": 0113, "name": "xxx", "status": "C","address":"xxx"}]}
I would do it that way:
@leewe01, Along with Heynowâs solution, we can also use DeserializeJson activity to convert a JSON to datatable in a single activity. The type Argument has to be changed to Datatable to get the require output.
[
{
"id":"0111",
"name":"xxx",
"status": "C",
"address":"xxx"
},
{
"id": "0112",
"name":"xxx",
"status": "C",
"address":"xxx"
},
{
"id": "0113",
"name": "xxx",
"status": "C",
"address":"xxx"
}
]
Refer the below sample,
JsonToDatatable.zip (2.2 KB)
Hi @heynow
Here is the example of my json file.
example.pdf (160.3 KB)
I have tried your suggested way. Unfortunately, the program has shown error (Output data table: Object reference not set to an instance of an object.) after the first ID. It canât loop the second ID.
I canât see DataTable creation part in your workflow, canât really replicate your issue.
Your âaddâ object keeps additional JObject inside, you can get value of it like this: item.Item("add").Item("add").ToString
Hi @heynow,
I havenât create the data table yet, as the execution stopped at Write line activity after looped the first ID. I checked the output from the Output panel.
Whatâs the way to keep it loops until the final ID? Thanks!
Hi @leewe01,
What kind of loop ? If you are using while then the best way make an incremantation its mean assign before and after loop. Condition should be counter >0. First assign counter = 0 last assign conter=counter +1.
Regards
@fudi5
Hi @heynow ,
Iâve added Add Data Row activity to the workflow, could you please advise whatâs the input for ArrayRow or DataRow?
Thanks.
Hi @Madhavi,
Here are the data that I wanted it in my data table.
id | name | status | add(name) | add (add) |
---|---|---|---|---|
001 | xxx | x | xxx | xxx |
002 | xxx | x | xxx | xxx |
003 | xxx | x | xxx | xxx |
⌠| ⌠| ⌠| ⌠| ⌠|
@leewe01
Use DeserializeJson activity and convert the json string to json object(jsonResult).
Loop through the array node in the json result. (jsonResult(âdataâ)
Add values of each array item into a datatable.
Once all the records are processed, Use write range activity to write into excel file.
@Madhavi Hi, Could you please tell the package name that include the " DeserializeJson â activity ?
Thanks !