Mappings and Transformations
This document outlines the API operations available for managing and applying mappings and transformations to product data.
Queries
applyMapping
Applies a saved mapping to transform data from a source into a specified target format. Specify both the source data and the mapping configuration to be used.
If no target format is provided, the default target format will be used.
Example:
generateMapping
Generates a mapping based on provided sample data and the desired target format. Use this to create a new mapping configuration by analyzing the structure and fields in the sample data.
If no target format is provided, the default target format will be used.
Example:
Additional Mapping Functions
Complex Field Mapping
Use advanced features like array selectors, nested field access, and constant values to customize data mapping.
Transformation Functions
Use transformation functions to modify data as part of the mapping process. These functions manipulate and convert field values, providing flexibility in how data is processed.
Function | Description | Example |
---|---|---|
capitalize() | Capitalizes the first letter of each word. | "product name" -> "Product Name" |
trim() | Removes whitespace from both ends of a string. | " product " -> "product" |
toNumber() | Converts a string to a number. | "123.45" -> 123.45 |
toBoolean() | Converts a value to a boolean. | "true" -> true, "1" -> true, "false" -> false, "0" -> false |
toString() | Converts a value to a string. | 123 -> "123" |
removeHTMLTags() | Strips HTML tags from a string. | "<p>Product description</p>" -> "Product description" |
convert(fromUnit, toUnit) | Converts between units. | convert("cm", "in") applied to "100" -> "39.37" |
split(separator, index) | Splits a string and returns the specified index. | split(",", "1") applied to "red,green,blue" -> "green" |
slice(start, end?) | Returns a portion of an array or string. | slice("1", "3") applied to "abcdef" -> "bcd" |
match(regex) | Returns the first match of a regular expression. | match("\\d+") applied to "Product123" -> "123" |
replace(search, replacement) | Replaces all occurrences of a substring. | replace("old", "new") applied to "old product" -> "new product" |
join(separator) | Joins array elements into a string. | join(", ") applied to ["red", "green", "blue"] -> "red, green, blue" |
Example usage of transformation functions in a mapping:
Choice Mappings
Use choice mappings to standardize and map specific source values to predefined target values, making it easier to handle categorical data or enumerations.
Combining choice mappings with transformation functions:
More complex example: