C#取消了风险化
本文关键字:取消 | 更新日期: 2023-09-27 17:57:39
在C#中,如何从下面的json中只选择"GroupType"。谢谢
{
"QnACollection": {
"QnA": [
{
"id": 11,
"question": "What was your childhood nickname?"
},
{
"id": 12,
"question": "In what city was your mother born?"
},
{
"GroupType": "RUN",
"id": 45,
"question": "What is the first name?"
}
]
}
}
使用Json.Net
var value = (string)JObject.Parse(json)
.Descendants().OfType<JProperty>()
.FirstOrDefault(p => p.Name == "GroupType");