Functions in JPath expressions
Some basic functions can be used in JPath expressions, such as using a function as part of a query.
The following table shows the basic functions that can be used in JPath expressions.
Function | Description |
---|---|
count(path) | Returns the number of items at a specific path expression.
|
base64_encode(expr) | Returns the base64 encoded value of a specific expression. |
base64_decode(expr) | Returns the base64 decoded value of a specific expression. |
url_encode(expr) | Returns the url encoded value of a specific expression. |
url_decode(expr) | Returns the url decoded value of a specific expression. |
min(path) | Returns the minimum value from an array at a specific path expression. |
max(path) | Returns the maximum value from an array at a specific path expression. |
time() | Returns time in milliseconds since epoch. |
New in V2 trunc(expr) | Returns the truncated value of a specific number expression. |
New in V2 round(expr) | Returns the rounded value of a specific number expression. |
New in V2 floor(expr) | Returns the floor of a specific number expression. |
New in V2 ceil(expr) | Returns the ceiling of a specific number expression. |
New in V2 random_number() | Returns a random floating point number between 0.0 and 1.0. |
New in V2 substring(expr, begin, end) | Returns the substring of a specific expression. |
New in V2 left(expr, length) | Returns the left portion of a specific expression. |
New in V2 right(expr, length) | Returns the right portion of a specific expression. |
New in V2 upper(expr) | Returns the uppercase value of a specific expression. |
New in V2 lower(expr) | Returns the lowercase value of a specific expression. |
New in V2 random_string(length) | Returns a random string of Latin alphabetic characters (a-z, A-Z). |
New in V2 empty(path) | Returns true if the value at a specific path expression is empty. |
New in V2 pad_left(expr, length, padValue) | Returns the left-padded value of a specific expression. |
New in V2 pad_right(expr, length, padValue) | Returns the right-padded value of a specific expression. |
New in V2 range(begin, end) | Returns a range of numbers as an array. |
New in V2 keys(path) | Returns the keys of the object at a specific path expression. |
New in V2 values(path) | Returns the values of the object at a specific path expression. |
New in V2 entries(path) | Returns the entries of the object at a specific path expression. |
The following table shows examples of basic functions that can be used in JPath expressions.
Example | Description | State | Expression | Result |
---|---|---|---|---|
Function in query | Uses a function as part of a query. | { "array": [ { "id": 1, "timestamp": 1186978597
}, { "id": 2, "timestamp": 1286978597 }, { "id": 3,
"timestamp": 17586978597 } ] } |
/array[@timestamp > time()] |
[ { "id": 3, "timestamp": 17586978597 } ] |
Find an event with the biggest timestamp | Uses the max() function in combination with a generated array of numbers. | { "array": [ { "id": 1, "timestamp": 1186978597
}, { "id": 2, "timestamp": 1286978597 }, { "id": 3,
"timestamp": 17586978597 } ] } |
max(/array/timestamp) |
17586978597 |