아래 Json에서 JsonConvert.DeserializeObject를 사용하는 방법
[{
"attributes" : {
"type" : "User",
"url" : "/xx/xx/xx"
},
"Id" : "1",
"Name" : "abc"
},{
"attributes" : {
"type" : "User",
"url" : "/xx/xx/xx"
},
"Id" : "2",
"Name" : "abc"
},{
"attributes" : {
"type" : "User",
"url" : "/xx/xx/xx"
},
"Id" : "3",
"Name" : "abc"
}]
이것들은 내 수업입니다
public class Attributes
{
public string type { get; set; }
public string url { get; set; }
}
public class RootObject
{
public Attributes attributes { get; set; }
public string Id { get; set; }
public string Name { get; set; }
}
나는 시도했다
var c = JsonConvert.DeserializeObject <RootObject>(jsonText);
Json은 실제로 RootObject
인스턴스 배열을 나타냅니다 . 이 시도:
var c = JsonConvert.DeserializeObject<RootObject[]>(jsonText);
또는 아마도
var c = JsonConvert.DeserializeObject<List<RootObject>>(jsonText);
또는
var c = JsonConvert.DeserializeObject<IEnumerable<RootObject>>(jsonText);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다