제발 도와주세요, C# 및 JSON으로 작업하고 있습니다. newtonsoft 네임 스페이스를 사용하여 C#에서 json 데이터를 deserialize하려고합니다.배열을 비 직렬화 json C#
class lastResponse
{
public string type { get; set; }
public Metadata metadata { get; set; }
// public string[] course { get; set; }
public List<object> course { get; set; }
public string publisher { get; set; }
}
public class Metadata
{
public string bookID { get; set; }
public string title { get; set; }
public string filename { get; set; }
}
이 코드 :
var errorMsg = JsonConvert.DeserializeObject<lastResponse>(downloader.LastResponse);
날이 오류를 제공합니다 :
"An unhandled exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'BookManager.lastResponse' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly."
날 내가 여기에 누락 알아낼 제발 도와주세요 여기
내 클래스입니다.
그것이 * 완전한 * 오류라고는 생각되지 않습니다. 이것이 예외 인 경우 전체 스택 추적을 게시하십시오. 이것이 컴파일 타임 오류라면 전체 오류를 게시하십시오. –
이 '문자열'을 'downloader.LastResponse' 표시 할 수 있습니까 –
@JonSkeet이 오류가 발생했습니다. "Newtonsoft.Json.JsonSerializationException'유형의 처리되지 않은 예외가 Newtonsoft.Json.dll에서 발생했습니다. 추가 정보 : Can not 형식에 JSON 객체 (예 : { "name": "value"})가 필요하기 때문에 현재 JSON 배열 (예 : [1,2,3])을 유형 'BookManager.lastResponse'로 역 직렬화합니다. – Red