REST API의 응답으로 아래 JSON이 표시됩니다.JSON을 C#에서 역 직렬화 할 수 없습니다.
{
"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