Hi there I am trying to convert JSON to Data-Table to write in a spreadsheet, attaching a sample file, I am keep getting error on passing the string to Deserialize Json Array activity but its throwing error, while trying with Deserialize it as JObj its able to parse it but unable to convert it to Data-Table to get the data in spreadsheet. This Json is complicated one
Such a retrieval task has in general following building blocks:
clear what is retrieved from static and from dynamic (e.g. loop over array, JOBject series)
We assume that you are e.g. interested on the JObjects from JArray hold under “value”
Following Statement allows you loop over these Objects (e.g. for each activity | TypeArgument: JObject)
myJObject("value").Cast(Of JObject)
then again check what is retrieved from this JObject static e.g.
and what comes dynamic e.g.
Just have a look on our description as we also introduced to different retrieval methods (direct Acces, acces with index into the array, SelekTokens method
When combining all these building blocks you can setup the retrieval for one DataTable Datarow and and let it loop over all needed “values” JObjects
So do I have to deal with each element separately ? although the JSON structure will be same but data will get added. have to extracted each and every data from all the properties and its array.
Identify how many excel rows will be created by an item from the values Array
e.g Value.customFields.templateProperties will create X rows per customfield
each entry in customfield Array will again create rows
similar you have to check for other involved arrays
From this analysis you can derive the needed nested loop structures and you can start with the implementation of the datarow column value extraction and generation
i cant attach a screenshot because the policies of organization
you should do :
build data table contains columns that you want to add in excel
2.use Deserialize JSON Array Activity and put as input the name of variable that contains json
and put the output in variable lets call it “JSOARR”.
for each item in “JSOARR”
and put inside for each, assign activity for fields you want to get from json and store inside it the filed from json object as string like below:
ID= convert.ToString(item.SelectToken(“ID”))
age=convert.ToString(item.SelectToken(“name”))
then use add data row and put id and age to store on build data table that you already created in step 1
use write range and put name of build data table variable to store on excel sheet
step 5 should be outside the scope of “for each”
But You need to define some Fixed Fields Not All the fields is a lot of information there and I don’t understrand how you will process this.
You need to adress Items in one line but select maximum 10 items not 100 items.