在Node.js中替换JSON对象的值

时间:2018-11-19 06:51:02

标签: node.js

我尝试使用代码

从下面的JSON对象替换键“信息”的值

"itsmdata.incidentParamsJSON.IncidentContainerJson.replace("Information",option);" 

但由于未定义对象而出错(附件)Error

{
    "ServiceName": "IM_LogOrUpdateIncident",
    "objCommonParameters": {
        "_ProxyDetails": {
            "ProxyID": 0,
            "ReturnType": "JSON",
            "OrgID": 1,
            "TokenID": null
        },
        "incidentParamsJSON": {
            "IncidentContainerJson": "{\"SelectedAssets\":null,\"Ticket\":{\"Caller_EmailID\":null,\"Closure_Code_Name\":null,\"Description_Name\":\"Account Unlock\",\"Instance\":null},\"TicketInformation\":{\"Information\":\"account locked out\"},\"CustomFields\":null}"
        },
        "RequestType": "RemoteCall"
    }
}

1 个答案:

答案 0 :(得分:0)

如果您尝试更新itsmdata的属性,可以尝试一下

 ArrayList<Contact>a = new ArrayList<>(500);
 Queue<Contact>b = new LinkedList<>();
 // maintain queue size of size 10
 int aIndex  = 0;
 for (int i = 0; i < 10; ++i) {
     b.add(a.get(aIndex++));
 }
 while (true) {
    if (b.isEmpty()) break; // break when all call are completed
    Contact frontValue = b.poll(); // get queue's first element and remove it
    // assign above contact to channel
    // put another contact from a to b
    if (aIndex  < a.size()) {
        b.add(a.get(aIndex++));
    }
 }