I need help converting json data in the attached file to data table. I can achieve this using a For loop which will be time consuming because there will be 15K+ rows of bulk data for each transaction. In the attached file array of “items” are to be consider as the data which I want to add in the data table and later export it as csv/excel file.
As a long oneliner after deserializing the JSON with
we can do:
JArray.FromObject(myJObject("items").Select(Function (a) new JObject(a.Select(Function (x,i) new JProperty("Col"&i.toString, x))))).toObject(Of DataTable)
Your one liner solution worked fantastic
Would you provide me the query which should get column names from json itself?
Also, I want to know what does “Decompose it to query syntax” means and why to do that?
Attached updated json file where array of Fields are consider as column names. TestJSON - Copy.json (2.6 KB)
JArray.FromObject(myJObject("items").Select(Function (a) new JObject(a.Select(Function (x,i) new JProperty(myJObject("_meta")("fields")(i).toString, x))))).toObject(Of DataTable)
However for learning purpose we would recommend to explore both approaches.