Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
替换Node.js中JSON对象的值_Node.js - Fatal编程技术网

替换Node.js中JSON对象的值

替换Node.js中JSON对象的值,node.js,Node.js,我尝试使用代码替换下面JSON对象中键“Information”的值 "itsmdata.incidentParamsJSON.IncidentContainerJson.replace("Information",option);" 但由于未定义对象而获取错误(附件) 如果您尝试更新其MDATA的属性,可以尝试以下操作 let str = itsmdata.objCommonParameters.incidentParamsJSON.IncidentContainerJson; itsmd

我尝试使用代码替换下面JSON对象中键“Information”的值

"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);