# JsonArray to Datatable

**URL:** <https://forum.uipath.com/t/jsonarray-to-datatable/208630>\
**Category:** Studio\
**Tags:** webapi, activities\
**Created:** [April 3, 2020, 7:00am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630 "2020-04-03T07:00:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 7:00am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/1 "2020-04-03T07:00:42Z")

</div>

Please it’s urgent guys,

Can anyone please help me for converting json array into datatable ? MY array format is different for each key value.  
Thanks in advance.

Regards,  
Hemal

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 3, 2020, 7:30am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/2 "2020-04-03T07:30:16Z")

</div>

@hemal Is it possible for you to send the json array ? Also have you tried using Deserialize Json Array Activity?

---

<div class="post-metadata">

**Author:** ![praneeth.peyyeti](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@praneeth.peyyeti](https://forum.uipath.com/u/praneeth.peyyeti)\
**Post date:** [April 3, 2020, 9:56am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/3 "2020-04-03T09:56:09Z")

</div>

hi hemal

please try this workflow which will convert jarray to datatable  
[JsonArrayToDT.xaml](https://forum.uipath.com/uploads/short-url/6ijVPcKUKLqveIk8NvKhGN1xarP.xaml) (11.5 KB)

Thank you

---

<div class="post-metadata">

**Author:** ![bnastase](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/bnastase/32/149186_2.png) [@bnastase](https://forum.uipath.com/u/bnastase)\
**Post date:** [April 3, 2020, 9:57am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/4 "2020-04-03T09:57:30Z")

</div>

Hi, deserialize the JSON, input the string and out we’ll have a json called out\_Json.

Depending on how your array is looking you can access individual elements from it with this syntax out\_Json.SelectToken(“items”).First(“title”).ToString, you’ll have to experiment around with the things between " " and see your results.

Then if you want to add those individual values in a datatable, if you already have the rows loop through it and use an assign with row(“ColumnName”) = valueFromJsonArray, or if you need to add rows, use a build data table to build your structure and then use an add data row. In the ArrayRow property you’ll need to use this syntax {valueFromJson1,valueFromJson2 etc}. As a reminder the structure of your array should follow the structure of your data table.

Bobby

---

<div class="post-metadata">

**Author:** ![praneeth.peyyeti](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@praneeth.peyyeti](https://forum.uipath.com/u/praneeth.peyyeti)\
**Post date:** [April 3, 2020, 10:26am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/5 "2020-04-03T10:26:51Z")

</div>

Hi hemal,

You can also try this method  
assign strJson= “[{‘name’: ‘John’,‘age’: 31,‘city’: ‘New York’},{‘name’: ‘praneeth’,‘age’: 32,‘city’: ‘chennai’}]”  
assign myDt = JsonConvert.DeserializeObject(of datatable)(strJson)

Thank you

---

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 10:33am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/6 "2020-04-03T10:33:13Z")

</div>

Hi @supermanPunch I already have tried with each and every scenario.  
Let me send you:  
{  
‘data’: [{  
‘date’: ‘09-OCT-2018’,  
‘initial\_date’: ‘29-APR-2018’,  
‘country’: ‘India’,  
‘report’: ‘Report’,  
‘id’: ‘’,  
}],  
‘reporting’: [{  
‘sal’: ‘Engineer’,  
‘first\_name’: ‘Hemal’,  
‘middle\_name’: ‘A’,  
‘last\_name’: ‘B’,  
‘suffix’: ‘’,  
‘institution’: ‘’,  
‘department’: ‘’,  
‘country’: ‘India’,  
}],  
‘patient’: [{  
‘first\_last\_name\_initials’: ‘UNKNOWN’,  
‘patient\_ID’: ‘’,  
‘birthdate’: ‘02-MAY-1980’,  
‘age’: ‘37’,  
‘units’: ‘Years’,  
‘sex’: ‘Male’,  
‘product\_indication’: [{  
‘reported\_indication’: [‘hypothyroidism.’, ‘thyroid (ARMOUR THYROID)’, ‘anxiety’],  
‘coded\_indication’: ’ ',  
}],  
}],  
}

I am not sharing all the data but kind of this is the foramt as thare are too many data with many key , value and even it has child key value also

---

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 10:35am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/7 "2020-04-03T10:35:25Z")

</div>

Thanks @praneeth.peyyeti Let me try 🙂

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 3, 2020, 10:35am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/8 "2020-04-03T10:35:36Z")

</div>

@hemal Ok, Can you also show us thee Expected Datatable format you want? With what are the headers you need? If you show it in an Excel File it would be good.

Do this if Solution isn’t found yet 😅

---

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 11:08am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/9 "2020-04-03T11:08:23Z")

</div>

Actually datatable would be like all keys would be headers

---

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 11:12am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/10 "2020-04-03T11:12:45Z")

</div>

@supermanPunch thanks in advance but i really don’t have much time for creating the excel. I am working on it. I will provide u in sometime til lthen can you please tell me how did you do

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 3, 2020, 11:18am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/11 "2020-04-03T11:18:54Z")

</div>

@hemal Do you need ‘date’, ‘initial\_date’, ‘country’ as headers or as Values to it’s Keys?

---

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 11:58am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/12 "2020-04-03T11:58:47Z")

</div>

[sample.xlsx](https://forum.uipath.com/uploads/short-url/5czS65YWvGrdFS5hxTjgxmxyuth.xlsx) (9.0 KB)

pfa just some data(s) only i have written

---

<div class="post-metadata">

**Author:** ![hemal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hemal/32/153775_2.png) [@hemal](https://forum.uipath.com/u/hemal)\
**Post date:** [April 3, 2020, 11:59am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/13 "2020-04-03T11:59:16Z")

</div>

that would be headers

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [April 3, 2020, 12:01pm UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/14 "2020-04-03T12:01:25Z")

</div>

@hemal ok. It looks a bit complicated to achieve it 😅, but i’ll try

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [April 5, 2020, 5:04pm UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/15 "2020-04-05T17:04:40Z")

</div>

@hemal  
have a look on this block

```
"data ": [{
		"date": "09 - OCT - 2018 ",
		"initial_date": "29 - APR - 2018",
		"country": "India",
		"report": "Report",
		"id": ""
	}], 

```

Here we do have an array. If additional element would occur then it could be the case that it comes into another structure or violate the strcture. So it has risk to disturb a fixed horizontal column structure

In such a scenario a more generic column structure is to suggest. An example could look like this:

 ![grafik](https://global.discourse-cdn.com/uipath/original/3X/6/a/6a9e715568876dc4b460cd224ea0ac8c01702d52.png)

so unforseen structures can be later deeper parsed as we do store the JSON string e.g.product\_indication

Also this structure can be transformed into the structure of your EXCEL if the processed structure is consistent for all records

**Find demo XAMl here**  
[hemal.xaml](https://forum.uipath.com/uploads/short-url/d3N9z4jdKUEHGhhPnXxB1QWR5zK.xaml) (17.1 KB)

As I was forced to correct your JSON (it was not valid by copy and paste) run the XAML against my JSON file from here  
[data.json](https://forum.uipath.com/uploads/short-url/n3ZOxRlenWxLUCu2MSTdsIKY8xd.json) (673 Bytes)

---

<div class="post-metadata">

**Author:** ![redda](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@redda](https://forum.uipath.com/u/redda)\
**Post date:** [May 12, 2020, 4:25pm UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/16 "2020-05-12T16:25:05Z")

</div>

Good Evening,  
I have the same issue.  
I have a Json Array.  
I could read the Json, Do a “Deserialize JSON Array” and do a loop “For Each” to filter with a Key “TEST1\_ID” and i can log the result. but i can’t write the result in a DataTable and in a Excel File.  
i’ll put an example of the json file. The structure is the same.

[  
{  
“\_idx” : “testlg”,  
“\_type” : “\_test”,  
“\_id” : “test1”,  
“\_version” : 1,  
“\_source” : {  
“TEST1\_ID” : “f358Y34958Y34958Y3458Y34958Y3495Y83495”,  
“TEST1\_NAME” : “GENDER\_U”,  
}  
},  
{  
“\_index” : “testlg”,  
“\_type” : “\_test”,  
“\_id” : “test1”,  
“\_version” : 1,  
“\_source” : {  
“TEST1\_ID” : “f358Y34958Y34958Y3458Y34958Y3495Y88787”,  
“TEST1\_NAME” : “GENDER\_U”,  
}  
}  
]

Thanks

---

<div class="post-metadata">

**Author:** ![Sakshi\_Jain](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sakshi_jain/32/183012_2.png) [@Sakshi\_Jain](https://forum.uipath.com/u/Sakshi_Jain)\
**Post date:** [January 13, 2021, 9:42am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/17 "2021-01-13T09:42:50Z")

</div>

How to get this into data table  
[  
{  
“id”: 15,  
“io-number”: “IND001000054”  
},  
{  
“id”: 16,  
“io-number”: “IND001000054”  
},  
{  
“id”: 17,  
“io-number”: “IND001000054”  
},  
{  
“id”: 18,  
“io-number”: “IND001000054”  
},  
{  
“id”: 20,  
“io-number”: “IND001000054”  
},  
{  
“id”: 21,  
“io-number”: “IND001000054”  
},  
{  
“id”: 22,  
“io-number”: “IND001000054”  
},  
{  
“id”: 23,  
“io-number”: “IND001000054”  
},  
{  
“id”: 24,  
“io-number”: “IND001000054”  
},  
{  
“id”: 25,  
“io-number”: “IND001000054”  
},  
{  
“id”: 26,  
“io-number”: “IND001000054”  
},  
{  
“id”: 27,  
“io-number”: “IND001000054”  
},  
{  
“id”: 28,  
“io-number”: “IND001000054”  
},  
{  
“id”: 29,  
“io-number”: “IND001000054”  
},  
{  
“id”: 30,  
“io-number”: “IND001000054”  
},  
{  
“id”: 31,  
“io-number”: “IND001000054”  
},  
{  
“id”: 32,  
“io-number”: “IND001000054”  
},  
{  
“id”: 33,  
“io-number”: “IND001000054”  
},  
{  
“id”: 34,  
“io-number”: “IND001000054”  
},  
{  
“id”: 35,  
“io-number”: “IND001000054”  
},  
{  
“id”: 36,  
“io-number”: “IND001000054”  
},  
{  
“id”: 37,  
“io-number”: “IND001000054”  
},  
{  
“id”: 38,  
“io-number”: “IND001000054”  
},  
{  
“id”: 39,  
“io-number”: “IND001000054”  
},  
{  
“id”: 40,  
“io-number”: “IND001000054”  
},  
{  
“id”: 41,  
“io-number”: “IND001000054”  
},  
{  
“id”: 42,  
“io-number”: “IND001000054”  
},  
{  
“id”: 43,  
“io-number”: “IND001000054”  
},  
{  
“id”: 44,  
“io-number”: “IND001000054”  
},  
{  
“id”: 45,  
“io-number”: “IND001000054”  
},  
{  
“id”: 46,  
“io-number”: “IND001000054”  
},  
{  
“id”: 47,  
“io-number”: “IND001000054”  
},  
{  
“id”: 48,  
“io-number”: “IND001000054”  
},  
{  
“id”: 49,  
“io-number”: “IND001000054”  
},  
{  
“id”: 50,  
“io-number”: “US032000050”  
},  
{  
“id”: 51,  
“io-number”: “IND001000054”  
},  
{  
“id”: 52,  
“io-number”: “IND001000054”  
},  
{  
“id”: 53,  
“io-number”: “US032000053”  
},  
{  
“id”: 54,  
“io-number”: “IND001000054”  
}  
]

---

<div class="post-metadata">

**Author:** ![NIVED\_NAMBIAR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nived_nambiar/32/169066_2.png) [@NIVED\_NAMBIAR](https://forum.uipath.com/u/NIVED_NAMBIAR)\
**Post date:** [January 13, 2021, 2:51pm UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/18 "2021-01-13T14:51:42Z")

</div>

Hi @Sakshi_Jain

There is a direct activitiy for converting json to datatable or

U can first deserialize the string to json and then add the Data as row to datatable by iterating through it

---

<div class="post-metadata">

**Author:** ![Sakshi\_Jain](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sakshi_jain/32/183012_2.png) [@Sakshi\_Jain](https://forum.uipath.com/u/Sakshi_Jain)\
**Post date:** [January 14, 2021, 8:11am UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/19 "2021-01-14T08:11:48Z")

</div>

I getting cannot convert Json array to json object . Please share the xaml file

---

<div class="post-metadata">

**Author:** ![Shawn\_Ngoh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shawn_ngoh/32/177033_2.png) [@Shawn\_Ngoh](https://forum.uipath.com/u/Shawn_Ngoh)\
**Post date:** [January 6, 2022, 9:38pm UTC](https://forum.uipath.com/t/jsonarray-to-datatable/208630/20 "2022-01-06T21:38:22Z")

</div>

Hi Nived, what direct activity are you talking about? I do not want to build a new datatable and add all these columns to mimic the json using the build datatable activity… it’s a bit cumbersome

[Next page](https://forum.uipath.com/t/jsonarray-to-datatable/208630.md?page=2)
