【发布时间】:2017-09-29 08:02:25
【问题描述】:
我从 REST API 获得以下 JSON 响应。
{
"data":{
"id":123,
"zoneid":"mydomain.com",
"parent_id":null,
"name":"jaz",
"content":"172.1 6.15.235",
"ttl":60,
"priority":null,
"type":"A",
"regions":[
"global"
],
"system_record":false,
"created_at":"2017-09-28T12:12:17Z",
"updated_at":"2017-09-28T12:12:17Z"
}
}
并尝试使用以下代码进行解析,但这不会导致正确的反序列化类型。
var model = JsonConvert.DeserializeObject<ResponseModel>(response);
下面是根据我在 JSON 响应中收到的字段的类。
public class ResponseModel
{
public int id { get; set; }
public string zone_id { get; set; }
public int parent_id { get; set; }
public string name { get; set; }
public string content { get; set; }
public int ttl { get; set; }
public int priority { get; set; }
public string type { get; set; }
public string[] regions { get; set; }
public bool system_record { get; set; }
public DateTime created_at { get; set; }
public DateTime updated_at { get; set; }
}
缺少什么?
【问题讨论】:
标签: c# json rest api json-deserialization