다음 JSON 파일이 있습니다.
{
"NAME": {
"ABC": {
"Score": 2,
"violations": []
},
"DEF": {
"Score": 4,
"violations": []
},
"GHI": {
"Score": 6,
"violations": ["badform"]
}
}
나는 클래스를 생성하여 이것을 deserilaize하려고하지만 null 또는 JSON.net 충돌이 발생하므로 클래스를 구성하는 것이 매우 어렵습니다. 누구든지 deserializer를 구성하는 가장 좋은 방법을 말해 줄 수 있습니까?
이것은 작동합니다 (적어도 JSON 파일 끝에 누락 된 "}"을 추가하면 여기서 작동합니다).
using ParsedData = Dictionary<string, Dictionary<string, A>>;
class A {
public int Score;
public string[] violations;
}
var parsed = JsonConvert.DeserializeObject<ParsedData>(…);
다른 버전 :
class A {
public int Score;
public string[] violations;
}
class B : Dictionary<string, A> {}
class C : Dictionary<string, B> {}
var parsed = JsonConvert.DeserializeObject<C>(…);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다