所以我有一組類:的Json解碼未解碼成複雜的對象
public class CallQueueRequest
{
public string ACK { get; set; }
public string ERROR { get; set; }
public Agent AGENT { get; set; }
public Skill SKILL { get; set; }
public string TIME { get; set; }
}
public class Agent
{
public string has_result { get; set; }
public List<Agents> agents { get; set; }
}
public class Agents
{
public string display_name { get; set; }
public string time_in_state { get; set; }
public string state { get; set; }
public string callstakentoday { get; set; }
public string avaya_skill_num { get; set; }
}
public class Skill
{
public string has_result { get; set; }
public string num_skills { get; set; }
public List<Skills> skills { get; set; }
}
public class Skills
{
public string display_name { get; set; }
public string avaya_skill_num { get; set; }
public string callsinqueue { get; set; }
public string callstoday { get; set; }
public string abantoday { get; set; }
public string lwt { get; set; }
public string ewt { get; set; }
public string servicelvl { get; set; }
public string avgspeedans { get; set; }
public string talktime { get; set; }
}
我有此JSON:
{
"ACK":"SUCCESS",
"ERROR":null,
"AGENT":{
"has_results":1,
"agents":[
{
"display_name":"John Doe",
"time_in_state":"378",
"state":"Acd",
"callstakentoday":null,
"avaya_skill_num":"81"
},
{
"display_name":"Jane Joe",
"time_in_state":"220",
"state":"Acd",
"callstakentoday":null,
"avaya_skill_num":"81"
}
]
},
"SKILL":{
"has_results":1,
"num_skills":1,
"skills":[
{
"display_name":"QueueName",
"avaya_skill_num":"81",
"callsinqueue":"1",
"callstoday":"29",
"abandtoday":"1",
"lwt":"74",
"ewt":"223",
"servicelvl":"86",
"avgspeedans":"35",
"talktime":"873"
}
]
},
"TIME":1355864270
}
我使用這個代碼:
object qr = JsonConvert.DeserializeObject(jsonString);
這似乎沒有正確地從Json轉換爲複雜的類。有人可以幫助我嗎?我認爲這只是一個小錯誤。
你有錯誤?如果不是,結果如何? – driis
序列化一個'CallQueueRequest',查看json,相應地進行調整。泡沫沖洗重複。 –
沒有錯誤。會發生什麼是qr.ChildrenTokens [0]是ACK,[1]是ERROR(都是好的),但是[2]的值是整個AGENT json集合。因此,不必去qr.ChildrenTokens [2] .ChildrenTokens [0]獲得John Doe的信息,我必須像[2]中的正則表達式那樣做。 – Sugitime