Skip to content

message.addBooleanToJSON

Signature: message.addBooleanToJSON(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 addBooleanToJSON
// Given a JSON message like:
message = qie.createJSONMessage(
   JSON.stringify(
      {
         "name": "David",
         "age": 23,
         "weight": "41kg"
      }
   )
);


// Example: value as Boolean
message.addBooleanToJSON(
   "/",           // nodePath - root node
   "lovesQIE",    // childNode - name of the new node
   true           // value (Boolean)
);


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

qie.warn(message);

// Resulting JSON:
// {
//     "name": "David",
//     "age": 23,
//     "weight": "41kg",
//     "lovesQIE": true,
//     "isActive": true
// }