Skip to content

message.isJSONNumber

Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.isJSONNumber.

Signature: message.isJSONNumber(nodePath)

Returns: Boolean matched - true if the given JSON nodePath is a number node

Find the first node that matches nodePath and evaluates if it is a number or not.

Note

This method only applies to JSON-formatted messages.

Parameters

Type Name Description Default
String nodePath the node path (XPath, HPath, Column ID, etc.)

Example

// Given a JSON message like:
message = qie.createJSONMessage(
    JSON.stringify(
        {
            "name": "David",
            "age": 22
        }
    )
);

// Check whether a node is a numeric value
if (message.isJSONNumber("/age")) {
    // The age node is a number, so it can be used in arithmetic without conversion.
}

if (!message.isJSONNumber("/name")) {
    // The name node is a string, not a number.
}