Skip to content

message.setJSONBoolean

Signature: message.setJSONBoolean(nodePath, value, instance*, forceNode*)

Returns: void

Find the node instance that matches nodePath (or create the node if it doesn't exist and forceNode = true) and set its value.

Note

Calling message.setJSONBoolean(nodePath, value) without the instance parameter sets the first node instance 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 or Boolean value the new node value
Integer instance* (optional) the match instance to set. Use 1 for the first instance. 1
Boolean forceNode* (optional) create the node if it doesn't exist true

Example

    // Examples of how to use setJSONBoolean
    // Given a JSON message like:
    message = qie.createJSONMessage(
       JSON.stringify(
          {
             "config": {
                "featureEnabled": false,
                "retryCount": 3
             },
             "status": "inactive"
          }
       )
    );


    // Example: value as Boolean (default behavior - first instance)
    message.setJSONBoolean(
       "/config/featureEnabled", // nodePath - target node
       true                      // value (Boolean)
    );


    // Example: value as String (will be converted to Boolean)
    message.setJSONBoolean(
       "/config/featureEnabled",
       "false"                  // value (String → Boolean)
    );


    // Example: specify instance (1-based index)
    message.setJSONBoolean(
       "/config/featureEnabled", // nodePath
       true,                     // value
       1                         // instance (first match)
    );


    // Example: create node if it does not exist (forceNode = true)
    message.setJSONBoolean(
       "/config/timeout", // nodePath (does not exist yet)
       "true",            // value (String → Boolean)
       1,                 // instance
       true               // forceNode - create if missing
    );

    // Resulting JSON:
    // {
    //     "config": {
    //         "featureEnabled": true,
    //         "retryCount": 3,
    //         "timeout": true
    //     },
    //     "status": "inactive"
    // }