我從REST API獲取下面的JSON響應。無法反序列化C中的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; }
}
缺少什麼?
很好的把戲。和json2csharp一樣,但在IDE中。謝謝 – OrcusZ