Sidebar

How can I push to an array in JSON message type?

0 votes
331 views
asked Sep 29, 2017 by gary-t-8719 (14,820 points)

1 Answer

0 votes
// convert string to message object
message = qie.createJSONMessage('{\n' +
   '   "dateRun": "' + qie.formatDate("yyyy-MM-dd HH:mm:ss") + '",\n' +
   '   "errors": []\n' +
   '}');

// create new error object
var error = qie.parseJSONString('{\n' +
   '      "reportName": "reportName",\n' +
   '      "system": "system",\n' +
   '      "error": "err"\n' +
   '   }');

// add to array
message.addObjectToJSONArray('/errors', error);

// create second error object
var error2 = qie.parseJSONString('{\n' +
   '      "reportName": "second reportName",\n' +
   '      "system": "system",\n' +
   '      "error": "second err"\n' +
   '   }');

// add to array
message.addObjectToJSONArray('/errors', error2);
answered Sep 29, 2017 by gary-t-8719 (14,820 points)
...