How do i convert a dynamic that contain json data result to a datatable?
I have tried everything i could but just could not make it into a datatable.
Below is my code and the jsondata result from a dynamic. Thanks a lot.
public class Response
{
public string ID { get; set; }
public string HostIp { get; set; }
public string HostMAC { get; set; }
public string HostType { get; set; }
public string ConnectedNetworkDeviceId { get; set; }
public string ConnectedNetworkDeviceIpAddress { get; set; }
public string ConnectedAPMacAddress { get; set; }
public string ConnectedAPName { get; set; }
public string VlanId { get; set; }
public string LastUpdated { get; set; }
public string AvgUpdateFrequency { get; set; }
public string Source { get; set; }
public string PointOfPresence { get; set; }
public string PointOfAttachment { get; set; }
public string ConnectedInterfaceId { get; set; }
public string ConnectedInterfaceName { get; set; }
}
public class RootObject
{
public List<Response> Response { get; set; }
public string Version { get; set; }
}
IRestResponse response2 = client.Execute(request);
dynamic hostdata = JsonConvert.DeserializeObject<dynamic>(response2.Content);
{{
"response": [
{
"id": "4c60d6a7-4812-40d6-a337-773af2625e56",
"hostIp": "1.1.1.1",
"hostMac": "00:24:d7:43:59:d8",
"hostType": "wireless",
"connectedNetworkDeviceId": "17184480-2617-42c3-b267-4fade5f794a9",
"connectedNetworkDeviceIpAddress": "55.1.1.3",
"connectedAPMacAddress": "68:bc:0c:63:4a:b0",
"connectedAPName": "AP7081.059f.19ca",
"vlanId": "600",
"lastUpdated": "1467837609856",
"avgUpdateFrequency": "1800",
"source": "300",
"pointOfPresence": "5a3bdb62-5def-40a1-be98-944ba2a7d863",
"pointOfAttachment": "5a3bdb62-5def-40a1-be98-944ba2a7d863"
},
{
"id": "3ef5a7c3-7f74-4e57-a5cb-1448fbda5078",
"hostIp": "1.1.1.2",
"hostMac": "5c:f9:dd:52:07:78",
"hostType": "wired",
"connectedNetworkDeviceId": "3ab14801-5c88-477d-bbb5-0aca5e5ba840",
"connectedNetworkDeviceIpAddress": "207.1.10.1",
"connectedInterfaceId": "1db9891e-9cee-4012-ba52-16df9db75a4a",
"connectedInterfaceName": "GigabitEthernet1/0/47",
"vlanId": "200",
"lastUpdated": "1467837601200",
"source": "200"
},
{
"id": "12f9c920-24fa-4d32-bf39-4c63813aecd8",
"hostIp": "1.1.1.3",
"hostMac": "e8:9a:8f:7a:22:99",
"hostType": "wired",
"connectedNetworkDeviceId": "24ac6aa8-7759-44d5-90a3-00c83e96583d",
"connectedNetworkDeviceIpAddress": "212.1.10.1",
"connectedInterfaceId": "81373176-c263-4284-9970-1cb5d72414fa",
"connectedInterfaceName": "GigabitEthernet1/0/47",
"vlanId": "200",
"lastUpdated": "1467836331564",
"source": "200"
}
],
"version": "1.0"
}}