Skip to content

message.addJSONBooleanBefore

Signature: message.addJSONBooleanBefore(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 Boolean value the value of the child node to add

Example

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


// Example: value as Boolean
message.addJSONBooleanBefore(
   "/name",      // nodePath - insert BEFORE this node
   "introvert",  // childNode - name of the new node
   false         // value (Boolean)
);


// Example: value as String (will be converted to Boolean)
message.addJSONBooleanBefore(
   "/introvert", // nodePath
   "isActive",   // childNode
   "true"        // value (String → Boolean)
);

// Resulting JSON:
// {
//     "isActive": true,
//     "introvert": false,
//     "name": "David",
//     "age": 44
// }