Json to DataTable

I have a http request to get a Json feedback like in below format:

{“token”:“IiOiJJVEJfRFLH.J8D3Q”,“message”:“success”}

How can i convert the json to Datatable and write it to excel?
I tried to use attached xaml but got below error:
Deserialize json
Message: Unexpected JSON token when reading DataTable. Expected StartArray, got StartObject. Path ‘’, line 1, position 1.

Also, if i only need to get the value of the token : IiOiJJVEJfRFLH.J8D3Q
How should i write my flow?

JsonToDT.xaml (7.2 KB)

1 Like

start with Deserialize JSON and output your data to a variable, for example: jobj_values
Now create a blank datatable and create an Int variable: i. have i = 0.
use a for each (not, for each row). in the values field put in = jobj_values.Item(“result”)
inside the for each, use Add Data Row.
Next, use the Assign to place data in the cells for each row. Here is an example of information i put in the assign activity:
Datatable.Rows(i)(“token”)
item.Item(“token”).ToString

Datatable.Rows(i)(“message”)
item.Item(“message”).ToString

at the end of the Assign activities, increment i by a count of 1.

1 Like

Do you mind to provide a sample xaml ?
I put System.Activities.Variable in Deserialize JSON argument
and what should i put in the “For Each”?
It said Item is not a member of System.Activities.Variable

create a blank datatable <----Do you mean to use the “Build Data Table” activities?

Hello,
In this video I do a lot of stuff with JSON (Chapter included) :

15:55 Datatable to JSON
17:50 JSON to Datatable

Thanks,
Cristian Negulescu

1 Like