source.isJSONObject¶
Use when: You want to read values from the original incoming message before any mapping changes. If you need the modified message during mapping, use message.isJSONObject.
Signature: source.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 source with both object and scalar values.
/* source:
{
"name": "David",
"age": 41,
"favorite movie": {
"title": "JAWS",
"release-date": 1978
},
"children": []
}
*/
// Evaluate whether the node at nodePath is a JSON object.
if (source.isJSONObject('/favorite movie')) {
// The favorite movie node is an object, so it has child nodes of its own.
}
// Evaluate a non-object node.
if (!source.isJSONObject('/age')) {
// The age node is a scalar value, not an object.
}