message.isJSONObject¶
Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.isJSONObject.
Signature: message.isJSONObject(nodePath)
Returns: Boolean matched - true if the given JSON nodePath is an object node
Find the first node that matches nodePath and evaluates if it is an object 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": 41,
"favorite movie": {
"title": "JAWS",
"release-date": 1978
},
"children": []
}
)
);
// Check whether a node is a JSON object
if (message.isJSONObject("/favorite movie")) {
// The favorite movie node is an object, so it has child nodes of its own.
}
if (!message.isJSONObject("/age")) {
// The age node is a scalar value, not an object.
}