I have JSON object in REST API response:
{
Result:
[
{
"id": 1,
"id_endpoint": 1,
"name": "Endpoint 1",
"description": "Endpoint 1",
"unit": "mmol",
"minthreshold": 30,
"maxthreshold": -15,
"id_device": 4,
"value": 7,
"time": "2016-12-24T21:20:19.000Z",
"address": "Endpoint 1",
"id_user": 1
}, {
"id": 2,
"id_endpoint": 1,
"name": "Endpoint 1",
"description": "Endpoint 1",
"unit": "mmol",
"minthreshold": 30,
"maxthreshold": -15,
"id_device": 4,
"value": 6,
"time": "2016-12-24T21:20:16.000Z",
"address": "Endpoint 1",
"id_user": 1
}, {
"id": 3,
"id_endpoint": 1,
"name": "Endpoint 1",
"description": "Endpoint 1",
"unit": "mmol",
"minthreshold": 30,
"maxthreshold": -15,
"id_device": 4,
"value": 8,
"time": "2016-12-24T21:18:38.000Z",
"address": "Endpoint 1",
"id_user": 1
}
],
StatusCode: 200
}
And if Error, they will get:
{
Result: null,
StatusCode: 404
}
I'm using JSON.NET and I've class DeviceInfo.cs
public class DeviceInfo
{
public int DeviceID {get;set;}
public int EndpointID {get;set;}
public string DeviceName {get;set;}
public double MinThreshold {get;set;}
public double MaxThreshold {get;set;}
public double CurrentValue {get;set;}
public DateTime ValueTime {get;set;}
public string EndpointAddress {get;set;}
public int IDUser {get;set;}
}
And my question is how to parse Result array in JSON object and stored it in DeviceInfo class?
See Question&Answers more detail:
os