我需要从JSON字符串中提取值以进行比较。我只需要验证它们是否按顺序排列(升序/降序)。我打算检查第一个和第二个“choices”并进行比较。我不需要更高级的功能。
编辑/更新: 在这种类型的查询中如何使用通配符(*)来跳过每个段?
编辑/更新: 在这种类型的查询中如何使用通配符(*)来跳过每个段?
string one = (string)o[this.Context[*WILDCARD*]["cid1"]].ToString();
/* this works, but has too many []
string one = (string)o[this.Context["partner"]]
[this.Context["campaign"]]
[this.Context["segment1"]]
[this.Context["segment2"]]
[this.Context["qid2"]]
["community"]
[this.Context["cid1"]].ToString();
*/
{
"partner": {
"campaign": {
"round1": {
"round2": {
"def123": {
"community": {
"choicec": 28
},
"user": {
"choice": "choicec",
"writeDateUTC": "2015-06-15T17:21:59Z"
}
}
},
"abc321": {
"community": {
"choicec": 33
},
"user": {
"choice": "choicec",
"writeDateUTC": "2015-06-15T17:21:59Z"
}
}
}
}
}
}
using Newtonsoft.Json
):dynamic d = JsonSerializer.Deserialize(yourJsonString);
然后使用d.partner.campaign.round1.def123.community.choicec
访问选择号码。 - cbrdynamic
?一定有一个具体的类存在。 - Amit Kumar Ghosh