Mapping Methods Reference

Transform data using string, object, and array methods


tip
Check out the Connectors Mapping Playground to experiment with and troubleshoot mapping expressions.

This reference documents all available transformation methods in the Connectors mapping language. You use methods with the ->method syntax to manipulate strings, objects, arrays, and other data types. Each method accepts arguments that can be JSON literals (numbers, strings, booleans, arrays, objects, and null) or special variables like $, $args, $this, or $config.

See the common mapping patterns pages in the response mapping docs for example snippets of common transformations.

String methods

Method Description Example
sliceReturns a slice of a stringfirstTwoChars: countryCode->slice(0, 2)
sizeReturns the length of a stringwordLength: word->size

Object methods

Method Description Example
entriesReturns a list of key-value pairskeyValuePairs: object->entries
sizeReturns the number of properties in an objectpropCount: object->size

Array methods

Method Description Example
filterReturns a new array containing all array items that match the criteria outlined in the first argument of filterevenNumbers: numbers->filter(@->mod(2)->eq(0))
findReturns the first item in the array that matches the criteria outlined in the first argument of findfirstEven: numbers->find(@->mod(2)->eq(0))
firstReturns the first value in a listfirstColor: colors->first
getFor a string, returns the character at the specified index. For an array, returns the item at the specified index. For an object, returns the property with the specified namethirdItem: items->get(2)
userName: user->get("name")
joinNotNullConcatenates an array of string values using the specified separator and ignoring null values$(["a", "b", null, "c"])->joinNotNull(',')
lastReturns the last value in a listlastColor: colors->last
mapMaps a list of values to a new list, or converts a single item to a listcolors: colors->map({ name: @ })
sliceReturns a slice of a listfirstTwoColors: colors->slice(0, 2)
sizeReturns the length of a listcolorCount: colors->size

Logical methods

Method Description Example
andGiven two or more values to compare, returns true if all of the values are truebothTrue: value1->and(value2, value3)
containsReturns true if the array contains the argumenthasRed: colors->contains("red")
eqReturns true if the value is equal to the argumentisActive: status->eq("active")
gtReturns true if the value is greater than the argumentisLarge: size->gt(100)
gteReturns true if the value is greater than or equal to the argumentisAtLeastTen: count->gte(10)
inReturns true if the list of arguments contains the valueisValidStatus: status->in("active", "pending", "complete")
ltReturns true if the value is less than the argumentisSmall: size->lt(50)
lteReturns true if the value is less than or equal to the argumentisWithinLimit: count->lte(100)
neReturns true if the value is not equal to the argumentisNotEmpty: value->ne("")
notInverts the boolean of the value. true becomes false, and false becomes trueisInactive: isActive->not
orReturns true if the value or any of the arguments are trueisValidOrDefault: isValid->or(useDefault)

Math methods

Method Description Example
addAdds the argument to the valuetotal: price->add(tax)
divDivides the value by the argumentaverage: sum->div(count)
modDivides the value by the argument and returns the remainderremainder: number->mod(5)
mulMultiplies the value by the argumentarea: width->mul(height)
subSubtracts the argument from the valuedifference: total->sub(discount)

Type coercion

Method Description Example
parseIntConverts a value to an Intcount: stringCount->parseInt
toStringConverts an input to a Stringid: userId->toString

Other methods

Method Description Example
echoEvaluates and returns its first argumentwrappedValue: value->echo({ wrapped: @ })
jsonStringifyConverts a value to a JSON stringjsonBody: body->jsonStringify
matchReplaces a value with a new value if it matches another valuestatus: status->match([1, "one"], [2, "two"], [@, "other"])
Feedback

Edit in VSCode

Ask Community