Basic Transformation Options
The table shows advanced transformation options, summary. and provides easy to copy/paste examples. Want to write the code yourself?
You can use advanced transformations to write complex JSONata expressions, which gives you significant flexibility to transform data according to your needs. See JSONata Docs to assist you in writing expressions.
For the list of Context Variables, see Context VariablesContext Variables.
Array transformation
Flatten
Flatten an array containing potentially nested arrays to a single array.
Example:
PluckBy
Extract the values of a property or deeply nested property of the objects within an array of objects.
Example:
Sort
Sort the items of an array of strings or numbers by value.
Example:
SortBy
Sort the items of an array of objects by the value of a plucked property of the objects within the array.
Example:
CountIf
Count all items of an array that are equal to a specific value.
Example:
CountIfBy
Count all items of an array of objects that contain a plucked property equal to a specific value.
Example:
Sum
Sum the values of an array of numbers.
Example:
SumBy
Sum the values of a plucked property of the objects within an array of objects.
Example:
Avg
Average the values of an array of numbers.
Example:
AvgBy
Average the values of a plucked property of the objects within an array of objects.
Example:
Min
Find the minimum value in an array of numbers.
Example:
MinBy
Find the minimum value of a plucked property of the objects within an array of objects.
Example:
Max
Find the maximum value in an array of numbers.
Example:
MaxBy
Find the maximum value of a plucked property of the objects within an array of objects.
Example:
Filter
Filter an array to the values that match a regular expression, a specific value, or non-null value.
Example:
FilterBy
Filter an array of objects to those that contain a property or deeply nested property whose values match a regular expression, a specific value, or non-null value.
Example:
Numeric transformations
Round
Adjust a number rounding or flooring it.
Example:
Floor
Adjust a number flooring it.
Example:
Ceil
Adjust a number ceiling it.
Example:
Absolute value
Compute the absolute value of a number.
Example:
Less than
Check if the first number is less than the second.
Example:
Less than or equal
Check if the first number is less than or equal to the second.
Example:
Greater than
Check if the first number is greater than the second.
Example:
Greater than or equal
Check if the first number is greater than or equal to the second.
Example:
Random
Generate a random number between inclusive lower and upper bounds.
Example:
Object transformations
Remove
Remove a property on an object.
Example:
Is Equal
Perform a deep comparison between two values to determine if they are equivalent.
Example:
Has By
Check if an object contains a property or deeply nested property.
Example:
$objectHasBy({ key: 1 }, “key”) => true
Pick
Create an object composed of the picked properties.
Example:
Pluck By
Extract the value of a property or deeply nested property of an object.
Example:
String Transformations
Strip
Remove all whitespace (tabs, spaces, and newlines) from both the left and right side of text. Spaces in between words will not be removed.
Example:
UUID v4
Generate a v4 universally unique identifier (UUID).
Example:
Hash
Compute that hash of a value.
Example:
Pad
Pad a string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
Example:
Pad Start
Pad a string on the left side if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
Example:
Pad End
Pad a string on the right side if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
Example:
$stringPadEnd(“abc”, 5,”h”) => “abchh”
Repeat
Repeat a string N times.
Example:
Camel Case
Convert a string to camel case.
Example:
Capitalize
Convert the first character of a string to upper case and the remaining to lower case.
Example:
Starts With
Check if a string starts with another.
Example:
Ends With
Check if a string ends with another.
Example:
Eval Expression
Parse and evaluate a string containing literal JSON or a JSONata expression.
Example:
Value Transformations
Is Array
Check if value is an array.
Example:
Is String
Check if value is a string.
Example:
Is Null Or Undefined
Check if value is null or undefined.
Example:
Is Object
Check if a value is an object.
Example:
From XML
Parse an XML string.
Example:
From YAML
Parse a YAML string.
Example:
From CSV
Parse a CSV string.
Example:
To XML
Serialize a value to XML.
Example:
To YAML
Serialize a value to YAML.
Example:
To CSV
Serialize a value to CSV.
Example: