message.addJSONBooleanAfter¶
Signature: message.addJSONBooleanAfter(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 addJSONBooleanAfter
// Given a JSON message like:
message = qie.createJSONMessage(
JSON.stringify(
{
"name": "David",
"age": 44
}
)
);
// Example: value as Boolean
message.addJSONBooleanAfter(
"/name", // nodePath - insert AFTER this node
"introvert", // childNode - name of the new node
false // value (Boolean)
);
// Example: value as String (will be converted to Boolean)
message.addJSONBooleanAfter(
"/introvert", // nodePath
"isActive", // childNode
"true" // value (String → Boolean)
);
// Resulting JSON:
// {
// "name": "David",
// "introvert": false,
// "isActive": true,
// "age": 44
// }