내가 비 직렬화하려는 일관성없는 Json으로 작업하고 있습니다. 문제는 언젠가는 Object를 가지며 때로는 배열이라는 것입니다. 이 작업을 수행하는 가장 좋은 방법은 무엇입니까? 변환기? 아래는 내 Json 데이터의 스 니펫입니다.Json.net 일관성없는 비 직렬화 JSON
[
{
"@class": "odd",
"td": [
{
"@class": "user",
"@onmouseover": "userInfo('469');",
"@onmouseout": "userInfo(0);",
"@onmousemove": "moveSlotInfo();",
"#text": " AAA"
},
{
"@id": "day-469-2014-04-07",
"@style": "vertical-align: top;",
"table": {
"@class": "ss",
"@cellspacing": "1",
"tbody": {
"tr": {
"td": {
"@class": "as",
"@style": "color: #ffffff; background-color: #4040ff;",
"@onmouseover": "this.className=(document.week_vs_doctor.activityId.value==-1?'sd':'sp');slotInfo('177935',false);",
"@onmouseout": "this.className='as';slotInfo(0,false);",
"@onmousemove": "moveSlotInfo();",
"#text": "KAVAul"
}
}
}
}
}
]
},
{
"@class": "even",
"td": [
{
"@class": "user",
"@onmouseover": "userInfo('262');",
"@onmouseout": "userInfo(0);",
"@onmousemove": "moveSlotInfo();",
"#text": " BBB"
},
{
"@id": "day-262-2014-04-07",
"@style": "vertical-align: top;",
"table": {
"@class": "ss",
"@cellspacing": "1",
"tbody": {
"tr": [
{
"td": {
"@class": "as",
"@style": "color: #ffffff; background-color: #4040ff;",
"@onmouseover": "this.className=(document.week_vs_doctor.activityId.value==-1?'sd':'sp');slotInfo('174318',false);",
"@onmouseout": "this.className='as';slotInfo(0,false);",
"@onmousemove": "moveSlotInfo();",
"#text": "KAVA "
}
},
{
"td": {
"@class": "as",
"@style": "color: #000000; background-color: #ffc0c0;",
"@onmouseover": "this.className=(document.week_vs_doctor.activityId.value==-1?'sd':'sp');slotInfo('174338',false);",
"@onmouseout": "this.className='as';slotInfo(0,false);",
"@onmousemove": "moveSlotInfo();",
"#text": "Dagbak"
}
}
]
}
}
}
]
}
]
문제는 tr 객체에 객체 또는 배열이있는 것입니다.
다음은 내 수업 조각
public class Td2
{
[JsonProperty("@class")]
public string TdClass { get; set; }
[JsonProperty("@style")]
public string style { get; set; }
[JsonProperty("@onmouseover")]
public string onmouseover { get; set; }
[JsonProperty("@onmouseout")]
public string onmouseout { get; set; }
[JsonProperty("@onmousemove")]
public string onmousemove { get; set; }
[JsonProperty("#text")]
public string text { get; set; }
}
public class Tr2
{
public Td2 td { get; set; }
}
public class Tbody2
{
[JsonProperty]
[JsonConverter(typeof(ScheduleJsonConverter<Tr2>))]
public List<Tr2> tr { get; set; }
}
public class Table
{
[JsonProperty("@cellspacing")]
public string cellspacing { get; set; }
public Tbody2 tbody { get; set; }
[JsonProperty("@class")]
public string tClass { get; set; }
}
"불일치"관련 스 니펫 (및/또는 강조 표시)을 포함 시키십시오. 열심히하지 마십시오. – user2864740
나는이 사람이 Tr 요소에 문제가 있다고 가정합니다. JSON에서는 단일 객체를 보여줍니다. 그러나 테이블에는 둘 이상의 행이있을 수 있습니다. – kmacdonald
@ user2864740 Json 스 니펫과 그 아래 텍스트를 보면 "tr 객체에 문제가 있습니다. 객체 또는 배열이 있습니다." 당신은 그것을 열심히하지 않을 것입니다;) – DreamNet