Search code examples
javascriptintegrationmaximo

Maximo Automation Script for Integration - JSON


I'm writing a script for integration to modify JSON input and save to maximo. First I converted the StructureData erData input to JSON object like this;

var resp = JSON.parse(erData.getDataAsString());

Then I modified the JSON object to add additional properties. How can I convert back my modified JSON object to StructureData erData so that I can save it to Maximo.

Thank you. Regards


Solution

  • To convert back the modified JSON object to StructureData erData by using JSON.stringify() javaScript method as follows :

    Say, your resp has following stringify data : '{"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"}'
    

    In case for Maximo to work, follow the JSON String from JSON Object Maximo

    Hope this helps !!