3 回答

TA貢獻1801條經驗 獲得超16個贊
由于您無法更改 Json 的格式,我想說以下類應該按預期工作:
public class UpdateResultSt
{
public bool isSuccess { get; set; }
public int elapsed { get; set; }
public Dictionary<string,string> results { get; set; }
public Dictionary<string,string> errors { get; set; }
}
然后你可以這樣寫:
routes_list.results["131351990802396920"]
獲取文本"updated"。
或者routes_list.results.Keys得到的名單id中的S results。
請參閱反序列化字典。

TA貢獻1865條經驗 獲得超7個贊
SuccessfulUpdateResult 和 FailedUpdateResult 的格式不正確。
應該是這樣的:
{
"isSuccess": true,
"elapsed": 54,
"results": [
0: { "id" : "131351990802396920", "text" : "updated"},
1: { "id" :"21034623651844830", "text" : "updated"},
2: { "id" :"112201011402879160", "text" : "updated"}
],
"errors": {
// same than SuccessfulUpdateResult
...
}
}

TA貢獻2003條經驗 獲得超2個贊
您的 json 字符串不代表您嘗試將其反序列化的對象圖。你的外部類應該有一個數組或結果和一個數組或類似于這樣的錯誤:
{
"isSuccess": true,
"elapsed": 54,
"results": [
{"id":"131351990802396920", "test":"updated"},
{"id":"21034623651844830","text":"updated"},
{"id":"112201011402879160", "text":"updated"}
],
"errors": [
{"id":"105933291602523100","test":"Error"},
{"id":"106574790922078090","text":"Error"},
{"id":"114439941021395940","text":"Error"},
{"id":"123574814601457710","text":"Error"}
]
}
您擁有的是一個結果類,其中包含三個名為 131351990802396920、21034623651844830、112201011402879160 的字段,因此它無法將其映射到您的對象。
- 3 回答
- 0 關注
- 223 瀏覽
添加回答
舉報