Skip to content

message.setAllJSONNumbers

Signature: message.setAllJSONNumbers(nodePath, value)

Returns: void

Find all nodes that match nodePath and set each nodes value.

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 Number value the new node value

Example

// Examples of how to use setAllJSONNumbers
// Given a JSON message like:
message = qie.createJSONMessage(
   JSON.stringify(
      {
         "people": [
            {
               "name": "Pablo",
               "soccer goals scored during season": 7
            },
            {
               "name": "Fernando",
               "soccer goals scored during season": 2
            }
         ]
      }
   )
);


// Example: value as Number (Java Integer)
message.setAllJSONNumbers(
   "/people/soccer goals scored during season", // nodePath - all matching nodes
   new java.lang.Integer(0)                     // value (Number)
);


// Example: value as String (will be converted to Number)
message.setAllJSONNumbers(
   "/people/soccer goals scored during season",
   "10"                                         // value (String → Number)
);


// Example: value as Number (JS number - note behavior)
message.setAllJSONNumbers(
   "/people/soccer goals scored during season",
   3                                          // value (JS Number → may result in decimal)
);

// Resulting JSON:
// {
//     "people": [
//         { "name": "Pablo",    "soccer goals scored during season": 3.0 },
//         { "name": "Fernando", "soccer goals scored during season": 3.0 }
//     ]
// }