Read the data from Jsonarry to convert into datatable

Hi team,
the below format are Jsonarry


str4jsonarry.txt (861 Bytes)

Extract the values from Jsonarray and expected out below

output :


Can any one help me

On of many options as a quick prototype in LINQ which can also be decomposed into essential activities:

Variables:


strJSON is your JSON as String

dtData = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(strJSON)

myLKDict =

(From d In dtData.AsEnumerable()
Let c4 = d("details").toString.Trim
Let se = System.Text.RegularExpressions.Regex.Match(c4,"(?<=line:).+(?=\.)").Value
Let arrValues = se.Trim().Split(","c)
Select t = Tuple.Create(d("name").toString.Trim, arrValues)).ToDictionary(Function (x) x.item1, Function (x) x.Item2)

arrRowJOs =

(From i In Enumerable.Range(0,myLKDict.First().Value.Length)
Let rp = myLKDict.Select( Function (kvp) New JProperty(kvp.Key, kvp.Value (i) ) )
Select jo = New JObject(rp)).toArray

dtResult = JArray.FromObject(arrRowJOs).ToObject(Of DataTable)

Visuals:

Ensure the also the following imports:


And:

For some trainings also have a look here:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

and feel free to add some cleanups e.g. ml String removal …

1 Like

Install the UiPath.WebAPI package, and use the Deserialize JSON activity. Set it to datatable.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.