我有一个 JSON 文档,其中包含一些数据,如下所示:
[
{
"id": 1,
"candidate": {
"firstName": "Subahar",
"lastName": "Kumar",
"alias": "S K"
},
"seatNo": "WKS14",
"checkInStatus": "NoShow",
"tests": [
{
"examCode": "OI4-759F",
"examName": "OI Professional of Fish",
"confirmationNo": "1-3966461574",
"keyCode": "3bdb987e-3623-4edc-9c24-ec9652ac6ac8",
"startDate": "1/4/2019",
"scheduledDuration": "1",
"startTime": "1200",
"endTime": "1300",
"resultStatus": "NotApplicable",
"testStatus": "Voided"
},
{
"examCode": "CY6-628F",
"examName": "CY Quiz of Art",
"confirmationNo": "1-6221969273",
"keyCode": "2e08c13a-2e52-4bc6-a771-af1670d00d15",
"startDate": "1/4/2019",
"scheduledDuration": "1",
"startTime": "1200",
"endTime": "1300",
"resultStatus": "NotApplicable",
"testStatus": "Voided"
},
}
],
我想要做的是在 JToken/JObject 中添加一个键值对,其中确认号是特定的。对于这种情况,我想将键值对添加("actions":"Launch, Ready, Done")到 {} 中的 Jtoken/对象,其中确认号"1-3966461574"位于测试数组中。这是我到目前为止所做的
JArray rosterData = GetRosterData();
foreach (var roster in rosterData.Children<JObject>()) {
foreach (var property in roster.Properties()) {
if (property.Name.Equals("tests")) {
}
}
}
这是我被困的地方,因为我不知道如何进一步进行。
紫衣仙女
相关分类