Orchestration
...
Transform Data
Basic Transformation Options
122 min
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 https //docs jsonata org/overview\ html to assist you in writing expressions for the list of context variables, see context variables docid\ ulk0z zxhuatvy90alrw8 array transformation flatten flatten an array containing potentially nested arrays to a single array example $arrayflatten(\[1, 2, \[3, 4]]) => \[1, 2, 3, 4] pluckby extract the values of a property or deeply nested property of the objects within an array of objects example $arraypluckby(\[{ “color” “brown”, “type” “dog” },{ “color” “beige”, “type” “cat” }],”type”) => \[“dog”,”cat”] sort sort the items of an array of strings or numbers by value example $arraysort(\[3, 4, 1], “desc”) => \[4, 3, 1] sortby sort the items of an array of objects by the value of a plucked property of the objects within the array example $arraysortby( \[{ “user” { “name” “foo” } }, { “user” { “name” ”bar” } }, { “user” { “name” “around” } }], “user name”, “asc” ) => \[{ “user” { “name” “around” } }, { “user” { “name” “bar” } }, { “user” { “name” “foo” } }] countif count all items of an array that are equal to a specific value example $arraycountif(\[43, 43, 41, 100], 43) => 2 countifby count all items of an array of objects that contain a plucked property equal to a specific value example $arraycountifby( 	\[{ "lastname" "doe" }, { "lastname" "test" }, { "lastname" "doe" }], 	"lastname", 	"doe" ) => 2 sum sum the values of an array of numbers example $arraysum(\[10, 30, 40]) => 80 sumby sum the values of a plucked property of the objects within an array of objects example $arraysumby(\[{ “age” 10 }, { “age” 30 }, { “age” 40 }], “age”) => 80 avg average the values of an array of numbers example $arrayavg(\[10, 30, 40]) => 26 6666 avgby average the values of a plucked property of the objects within an array of objects example $arrayavgby(\[{ “age” 10 }, { “age” 30 }, { “age” 40 }], “age”) => 26 6666 min find the minimum value in an array of numbers example $arraymin(10, 30, 40]) => 10 minby find the minimum value of a plucked property of the objects within an array of objects example $arrayminby(\[{ “age” 10 }, { “age” 30 }, { “age” 40 }], “age”) => 10 max find the maximum value in an array of numbers example $arraymax(\[10, 30, 40]) => 40 maxby find the maximum value of a plucked property of the objects within an array of objects example $arraymaxby(\[{ “age” 10 }, { “age” 30 }, { “age” 40 }], “age”) => 40 filter filter an array to the values that match a regular expression, a specific value, or non null value example $arrayfilter(\[1, 2, 3, 4, 5, 3], 3) => \[3, 3] 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 $arrayfilterby(\[{ “age” 10 }, { “age” 30 }, { “age” 40 }], “age”, 10) => \[{ “age” 10 }] numeric transformations round adjust a number rounding or flooring it example $numericround(123 6, 0) => 124 floor adjust a number flooring it example $numericfloor(1234, 1) => 1230 ceil adjust a number ceiling it example $numericceil(1234, 1) => 1240 absolute value compute the absolute value of a number example $numericabs( 1) => 1 less than check if the first number is less than the second example $numericlessthan(2, 7) => true less than or equal check if the first number is less than or equal to the second example $numericlessthanorequal(20, 7) => false greater than check if the first number is greater than the second example $numericgreaterthan(2, 7) => false greater than or equal check if the first number is greater than or equal to the second example $numericgreaterthanorequal(7, 7) => true random generate a random number between inclusive lower and upper bounds example $numericrandombasic(1, 10, “no”) => 3 object transformations remove remove a property on an object example $objectremove({ “name” “john” }, “name”) => {} is equal perform a deep comparison between two values to determine if they are equivalent example $objectisequal({ “age” 30, “name” “joe” }, { “age” 30, “name” “joe” }) => true 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 $objectpick({ “person” { “name” “joe” }, “age” 30 }, “age”) => { “age” 30 } pluck by extract the value of a property or deeply nested property of an object example $objectpluckby({ “person” { “name” “joe” }, “age” 30 }, “person name”) => “joe” 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 $stringstrip(“ hello word ”) => “hello word” uuid v4 generate a v4 universally unique identifier (uuid) example $stringuuidv4() => “be407787 14e1 47d1 9b25 9eaa624f7a5f” hash compute that hash of a value example $stringhash(“data”, “md5”) => “8d777f385d3dfec8815d20f7496026dc” 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 $stringpad('abc', 8) => “ abc “ 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 $stringpadstart(“abc”, 5,”h”) => “hhabc” 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 $stringrepeat(“abc”, 2) => “abcabc” camel case convert a string to camel case example $stringcamelcase(“hello world”) => “helloworld” capitalize convert the first character of a string to upper case and the remaining to lower case example $stringcapitalize(“hello world”) = “hello world” starts with check if a string starts with another example $stringstartswith(“abc”, “a”) => true ends with check if a string ends with another example $stringendswith(“abc”, “c”) => true eval expression parse and evaluate a string containing literal json or a jsonata expression example $stringevalexpression(“\[1,$string(number),3]”, { “number” 2 }) => \[1,”'2”, 3] value transformations is array check if value is an array example $valueisarray(\[1, 4, 4]) => true is string check if value is a string example $valueisstring(“data”) => true is null or undefined check if value is null or undefined example $valueisnullorundefined(null) => true is object check if a value is an object example $valueisobject({}) => true from xml parse an xml string example $valuesfromxml(“\<a/>”) => {“a” {}} from yaml parse a yaml string example $valuesfromyaml( “version 1 0 0\ndependencies \n yaml ^1 10 0\npackage \n exclude \n idea/ \n gitignore\n” ) => { “version” “1 0 0”, “dependencies” { “yaml” “^1 10 0”}, “package” {“exclude” \[“ idea/ ”, “ gitignore”]}} from csv parse a csv string example $valuefromcsv(“eruid,description\nbatman,uses technology\nsuperman,flies through the air”) => \[ { “description” “uses technology”, “eruid” “batman” }, { “description” “flies through the air', “eruid” “superman” } ] to xml serialize a value to xml example $valuestoxml({ “a” {} }) => “\<a/>” to yaml serialize a value to yaml example $valuestoyaml({ “version” “1 0 0”, “dependencies” { “yaml” “^1 10 0” }, “package” { “exclude” \[“ idea/ ”, “ gitignore”] } }) => “version 1 0 0\ndependencies \n yaml ^1 10 0\npackage \n exclude \n idea/ \n gitignore\n” to csv serialize a value to csv example $valuestocsv(\[ { “eruid” “batman”, “description” “uses technology” }, { “eruid” “superman”, “description” “flies through the air” } ]) => “eruid,description\nbatman,uses technology\nsuperman,flies through the air\n”