我有一个json字符串,如下所示:
"{
"TotalAmount":{"XPos":"100","YPos":"750"},
"title":{"XPos":"250","YPos":"800"},
"ListSetting":{
"listId":"batchlist",
"listXPos":"30",
"listYPos":"700",
"listCols":"["seq","RemitType"]"
}
}"
我想将此字符串解析为键的字典,如TotalAmount,title和ListSetting,但是当按以下方式进行DeserializeObject时,会发生错误。
JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonStr);
An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: After parsing a value an unexpected character was encountered: s. Path 'ListSetting.listCols', line 1, position 166.
看起来像“ listCols”正在引起问题,但我不知道如何解决。 有人可以帮忙吗?谢谢。
答案 0 :(得分:3)
像"
一样删除listcols
数组周围的引号"listCols":["seq","RemitType"]
,否则根本不会被视为数组对象,显然反序列化将失败