Skip to content

Library reference

Jolt ships with 79 built-in methods. Any of them can be called directly or piped with ->, and most accept either a JSON Path or a value. Range variables can be passed to nearly all of them.

Valid in says where a method can appear: in a property value, in a property name, as a statement inside a #using block, or as a case inside a #match.

Method Description Valid in
#exists Returns true if the provided value is not null, false otherwise. Property value
#isMissing Returns true if the provided path does not exist in the source document, false otherwise. Property value
#isNull Returns true if the provided value is null, false otherwise. Property value
#valueOf Gets the value of a property at the specified path. Property value
Method Description Valid in
#eval Evaluates an arbitrary expression, either from a path or literal value, and returns the result. (unsafe) Property name, Property value
#if Evaluates one of two expressions depending on a boolean condition. Property value
#includeIf Includes the property’s object when a path or condition is true, and sets it to null otherwise. Property name
#try Evaluates an expression, and if it fails, evaluates a lambda with the exception and returns that result instead. Property value
Method Description Valid in
#foreach Loops over the elements of an array or the properties of an object, transforming each with a content template. Property name
#nameOf Returns the name of the property currently being iterated by a loop variable. Property name
#using Binds a path or value to a range variable so statements can modify it. Property name
Method Description Valid in
#removeAt Removes a JSON node at a variable-based path. Statement
#setAt Adds or modifies a JSON node at a variable-based path, creating missing parents. Statement
#when Executes one or more statements when a boolean expression is true. Statement
Method Description Valid in
#default Always matches; use as the final catch-all case. Match case
#given Matches when an arbitrary boolean expression is true. Match case
#is Matches the value against a type, array pattern, object pattern, or scalar literal. Match case
#match Matches a value against cases from top to bottom and returns the value of the first one that matches. Property name
Method Description Valid in
#append Returns a string or array made by appending one or more strings or arrays. Property value
#contains Returns true when an array or string contains the provided value. Property value
#indexOf Returns the zero-based index of the first occurrence of the provided value. Property value
#length Returns the length of a string or array value. Property value
#reverse Returns the string or array with its elements in reverse order. Property value
Method Description Valid in
#endsWith Returns true if a string ends with the provided substring, false otherwise. Property value
#isRegexMatch Returns true if a string matches the provided regular expression, false otherwise. Property value
#joinWith Returns a string that joins all elements of an array with the provided delimiter. Property name, Property value
#regexReplace Returns the string with all matches of a regular expression replaced with another value. Property value
#replace Returns the string with all occurrences of a substring replaced with another value. Property value
#splitOn Returns an array of substrings by splitting a string on the provided delimiter. Property value
#startsWith Returns true if a string starts with the provided substring, false otherwise. Property value
#substring Returns the part of a string that falls within the provided range. Property value
#toLowerCase Returns the lowercase version of a string value. Property value
#toUpperCase Returns the uppercase version of a string value. Property value
#trim Returns the string with all leading and trailing whitespace removed. Property value
#trimEnd Returns the string with all trailing whitespace removed. Property value
#trimStart Returns the string with all leading whitespace removed. Property value
Method Description Valid in
#any Returns true if an array or string has contents, or, with a lambda, if any element matches. Property value
#distinct Returns the items with distinct values of a specified property, or distinct scalar values. Property value
#flatten Returns a single array by recursively flattening an array of nested arrays. Property value
#orderBy Returns the array in ascending order of a selected value. Property value
#orderByDesc Returns the array in descending order of a selected value. Property value
#reduce Accumulates a single value by applying a two-parameter lambda to each element, with an optional seed. Property value
#select Returns an array of the results of projecting each element. Property value
#skip Returns the array without its leading elements, up to the specified count. Property value
#skipWhile Returns the array without the leading elements that satisfy a condition. Property value
#slice Returns the part of an array that falls within the provided range. Property value
#take Returns the leading elements of an array, up to the specified count. Property value
#takeWhile Returns the leading elements of an array that satisfy a condition. Property value
#where Returns the elements of an array that match a predicate. Property value
#zip Combines two arrays pairwise using a two-parameter lambda. Property value
Method Description Valid in
#average Returns the average of an array of numbers, optionally after a projection. Property value
#groupBy Groups an array’s elements by a selected value into key and results pairs. Property value
#max Returns the maximum of an array of numbers, optionally after a projection. Property value
#min Returns the minimum of an array of numbers, optionally after a projection. Property value
#sum Returns the total of an array of numbers, optionally after a projection. Property value
#summarizeWith Applies an aggregate expression to each group’s key and results. Property value
Method Description Valid in
#keysFrom Returns an array of the property names of an object. Property value
#merge Deep-copies and merges two or more objects, with later values taking precedence. Property value
#valuesFrom Returns an array of the property values of an object. Property value
Method Description Valid in
#roundTo Returns a number rounded to the specified number of decimal places. Property value
Method Description Valid in
#addDays Returns an ISO 8601 date and time with the specified number of days added. Property value
#addHours Returns an ISO 8601 date and time with the specified number of hours added. Property value
#addMinutes Returns an ISO 8601 date and time with the specified number of minutes added. Property value
#currentDateTime Returns the current local date and time as an ISO 8601 string. Property value
#currentDateTimeUtc Returns the current UTC date and time as an ISO 8601 string. Property value
#formatDateTime Formats a date and time string using the provided format string. Property value
#parseDateTime Parses a string into an ISO 8601 date and time, requiring an exact format when one is given. Property value
Method Description Valid in
#isArray Returns true if the value is an array, false otherwise. Property value
#isBoolean Returns true if the value is a boolean. Property value
#isDecimal Returns true if the value is a floating point number. Property value
#isEmpty Returns true if the value is an array or string with no contents, false otherwise. Property value
#isInteger Returns true if the value is a whole number. Property value
#isObject Returns true if the value is an object, false otherwise. Property value
#isString Returns true if the value is a string. Property value
#toBoolean Returns a value converted to a boolean. Property value
#toDecimal Returns a value converted to a floating point number. Property value
#toInteger Returns a value converted to a whole number. Property value
#toString Returns the string representation of a value. Property value
Method Description Valid in
#transformWith Transforms a sub-document with a registered, standalone transformer. Property value

Missing a method you need? Raise an issue.