JSON Array to DataTable


#1

I have a JSON object with an array inside (“logins”), that I would like to either convert to a data table, or just iterate over each element in the array. I have deserialized it into a JSON object, but I’m not sure how to extract each field from each row…

{
  "logins": [
    {
      "id": 2,
      "username": "test",
      "password": "test123",
      "enabled": true
    },
    {
      "id": 3,
      "username": "test2",
      "password": "test123",
      "enabled": true
    },
    {
      "id": 4,
      "username": "test3",
      "password": "test123",
      "enabled": true
    }
	]
}

#2

https://www.aspforums.net/Threads/124155/How-to-convert-json-string-to-Datatable-using-C-and-VBNet-in-ASPNet/

check this page it may help to solve your problem

thanks
yogananda


#3

Use Deserialize json array and assign YourJsonObject(“logins”).ToString then you can loop through hope it works for you :+1:


#4

Try this
DataTable = JsonConvert.DeserializeObject(Of DataTable)(json_data)

Thanks
JothyPrasanth M