Skip to content

message.addJSONNumberAfter

Signature: message.addJSONNumberAfter(nodePath, childNode, value)

Returns: void

Add the specified childNode to the first node that matches nodePath.

Note

This method only applies to JSON-formatted messages.

Parameters

Type Name Description Default
String nodePath the node path (XPath, HPath, Column ID, etc.)
String childNode the name of the child node to add
String or Number value the value of the child node to add

Example

// Examples of how to use addJSONNumberAfter
// Given a JSON message like:
message = qie.createJSONMessage(
   JSON.stringify(
      {
         "name": "David",
         "age": 44
      }
   )
);


// Example: value as String (will be converted to Number)
message.addJSONNumberAfter(
   "/name",            // nodePath - insert AFTER this node
   "numberOfKids",     // childNode - name of the new node
   "6"                 // value (String → Number)
);


// Example: value as Number (Java Integer)
message.addJSONNumberAfter(
   "/numberOfKids",          // nodePath
   "yearsMarried",           // childNode
   new java.lang.Integer(20) // value (Number)
);


// Example: value as Number (JS number - note behavior)
message.addJSONNumberAfter(
   "/yearsMarried",  // nodePath
   "rating",         // childNode
   4                 // value (JS Number → may result in decimal)
);

// Resulting JSON:
// {
//     "name": "David",
//     "numberOfKids": 6,
//     "yearsMarried": 20,
//     "rating": 4.0,
//     "age": 44
// }