source.isJSONString¶
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.isJSONString.
Signature: source.isJSONString(nodePath)
Returns: Boolean matched - true if the given JSON nodePath is a string node
Find the first node that matches nodePath and evaluates if it is a string 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 string, object, and array values.
/* source:
{
"name": "David",
"age": 41,
"favorite movie": {
"title": "JAWS",
"release-date": 1978
},
"children": []
}
*/
// Evaluate whether the node at nodePath is a JSON string.
if (source.isJSONString('/name')) {
// The name node is a string value.
}
// Evaluate a non-string node.
if (!source.isJSONString('/age')) {
// The age node is a number, not a string.
}