You can enter the functions at last of a path, the input to a function is the output of the path expression. The function output transcripts the function itself to use the function place after the path and argument, to pass the functions. For example: $.store.book.length().
Following table contains all the functions supported by the JSON Path library:
Function | Description | Return type |
---|---|---|
min() | Provide the min value of an array of numbers. | Double |
max() | Provide the max value of an array of numbers. | Double |
avg() | Provide the average value of an array of numbers. | Double |
stddev() | Provide the standard deviation value of an array of numbers. | Double |
length() | Provide the length of an array. | Integer |
sum() | Provide the sum value of an array of numbers. | Double |
keys() | Provide the property keys (An alternative for terminal tilde ~ ). |
Set<E> |
concat(X) | Provide a concatenated version of the path output with a new item. | Same as input |
append(X) | Add an item to the json path output array. | Same as input |
Custom Functions
A custom function for date transform is present in the Kafka Mapper, which takes a String input parameter which denotes the source date format use of the function $.timestamp.transform_date(\"yyyy-MM-dd HH:mm\").
If the date format is present in the JSON data itself, then use $.timestamp.transform_date($.dateFormat)
For example, some of the supported date time formats:
Format | Example |
---|---|
yyyy-MM-dd*HH:mm:ss | 2022-07-04*13:23:55 |
yyyy-MM-dd*HH:mm:ss:SSS | 2022-10-30*02:47:33:899 |
yy-MM-dd HH:mm:ss SSS | 22-06-26 02:31:29 573 |
yyyy MMM dd HH:mm:ss.SSS*zzz | 2018 Apr 13 22:08:13.211*PDT |
Note: Other supported and pre-defined date time formats are present in the Java 11 date time library.