JSON을 개체로 역 직렬화하는 데 문제가 있습니다. 나는 몇 가지 답변을 읽었지만 아무도 나를 도왔습니다.
이것은 내 JSON 파일입니다.
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"blog": {
"title": "title",
"name": "name",
"url": "url"
}
}
}
그리고 이것은 내 수업입니다.
public class TextInfo
{
public class Meta
{
public int status { get; set; }
public string msg { get; set; }
}
public class Blog
{
public string title { get; set; }
public string name { get; set; }
public string url { get; set; }
}
public class Response
{
public Blog blog { get; set; }
}
public class RootObject
{
public Meta meta { get; set; }
public Response response { get; set; }
}
}
이제 json을 그렇게 역 직렬화하려고 시도했지만 데이터를 조작하는 방법을 모르겠습니다.
TextInfo txt = JsonConvert.DeserializeObject<TextInfo>(json);
이걸 알아 내도록 도와 주실 수 있나요? 미리 감사드립니다.
세개:
오류 메시지 / 로그를 제공 할 수 있습니까?
하나의 항목 또는 여러 항목을 구문 분석합니까? 두 번째 경우 :var txt = JsonConvert.DeserializeObject<List<TextInfo>>(JSONstr);
다음을 시도하십시오.
public class Meta
{
public int status { get; set; }
public string msg { get; set; }
}
public class Response
{
public Blog blog { get; set; }
}
public class Blog
{
public string title { get; set; }
public string name { get; set; }
public string url { get; set; }
}
public class TextInfo
{
public Meta meta { get; set; }
public Response response { get; set; }
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다