2

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

  • As an aside, the JSON Mapping application in Maximo might allow you to do the same thing without the need for code, depending on how complicated the thing you are doing is. – Dex Jun 30 '20 at 21:06
  • 1
    You could improve the quality of your question by showing some more code. You can protect your privacy by using generic names and/or values, but it would help us help you and help your question benefit other users if you supplied a [example]. – Preacher Jul 02 '20 at 23:09

2 Answers2

1

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 !!

solanki...
  • 4,982
  • 2
  • 27
  • 29
  • Yes, I did that earlier. Unfortunately, maximo couldn't process that as it is read as string type. Here is the error: "java.lang.String incompatible with psdi.iface.mic.StructureData" – Razaleigh Wiseman Jun 30 '20 at 06:55
1

Looking at the Maximo JavaDocs for StructureData, and not being sure how thorough it is, you could try StructureData(JSON.stringify(resp)). If that doesn't work, you may need to convert your JSON to XML and pass the XML as a byte array to a StructureData constructor.

Alternatively, use the StructureData methods to manipulate erData directly, without converting to/from JSON.

Preacher
  • 2,127
  • 1
  • 11
  • 25