替换Node.js中JSON对象的值
我尝试使用代码替换下面JSON对象中键“Information”的值替换Node.js中JSON对象的值,node.js,Node.js,我尝试使用代码替换下面JSON对象中键“Information”的值 "itsmdata.incidentParamsJSON.IncidentContainerJson.replace("Information",option);" 但由于未定义对象而获取错误(附件) 如果您尝试更新其MDATA的属性,可以尝试以下操作 let str = itsmdata.objCommonParameters.incidentParamsJSON.IncidentContainerJson; itsmd
"itsmdata.incidentParamsJSON.IncidentContainerJson.replace("Information",option);"
但由于未定义对象而获取错误(附件)
如果您尝试更新其MDATA的属性,可以尝试以下操作
let str = itsmdata.objCommonParameters.incidentParamsJSON.IncidentContainerJson;
itsmdata.objCommonParameters.incidentParamsJSON.IncidentContainerJson = str.replace(/Information/gi, option);
incidentParamsJSON位于objCommonParameters内。您应该使用objCommonParameters.incidentParamsJSON。顺便说一句,您不应该使用替换对象中的键replace@Dineshundefined:我想替换该特定键“信息”的值Hi KibGZr,感谢您的解决方案,现在我没有收到错误,但新值不会被替换。
let str = itsmdata.objCommonParameters.incidentParamsJSON.IncidentContainerJson;
itsmdata.objCommonParameters.incidentParamsJSON.IncidentContainerJson = str.replace(/Information/gi, option);