API Json response to datatable

Hello guys. I have an API response in json format like this:
How can i convert it to Datatable? Been trying with newtonsoft, but was unsucsesful

Hi @Povilas_Jonikas

Deserialize JSON (Output: jsonObject) -> Assign: numberString = jsonObject("number").ToString
Assign: numbers = numberString.Split(","c)

Build Data Table (Output: dataTable)
   Add  Column Name: ("Number", "Valid", "Local Format", "International Format")

For Each (item in numbers)
   Assign: dataRow = dataTable.NewRow()
   dataRow("Number") = item
   dataRow("Valid") = jsonObject("valid").ToString
   dataRow("Local Format") = jsonObject("local_format").ToString
   dataRow("International Format") = jsonObject("international_format").ToString
   Add Data Row (Input: dataRow) to dataTable

Hope it helps!!

Deserialize the JSON with:
output: myJObject | TypeArgument: JObject

then we can convert this JObject to a DataTable by:

myDataTable =
Newtonsoft.Json.Linq.JArray.FromObject(new JObject(){myJObject}).ToObject(Of DataTable)

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