我正在编写一个集成脚本来修改 JSON 输入并保存到 maximo。首先,我将 StructureData erData 输入转换为 JSON 对象,如下所示;
var resp = JSON.parse(erData.getDataAsString());
然后我修改了 JSON 对象以添加其他属性。如何将修改后的 JSON 对象转换回 StructureData erData,以便将其保存到 Maximo。
谢谢。问候
最佳答案
使用 JSON.stringify()
javaScript 方法将修改后的 JSON 对象转换回 StructureData erData,如下所示:
假设,您的 resp
具有以下字符串化数据:'{"result":true, "count":42} '
var resp = JSON.parse(erData.getDataAsString()); // resp = '{"result":true, "count":42}';
resp['name'] = 'Dummy'; // a new property with key name and value Dummy is created and added in resp
console.log(resp); // you get the new resp object
console.log(JSON.stringify(resp)); // '{"result":true, "count":42, "name":"Dummy"}'
如果 Maximo 可以正常工作,请按照 JSON String from JSON Object Maximo 操作
希望这有帮助!!
关于javascript - 用于集成的 Maximo 自动化脚本 - JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62650132/