Introduction
The Format: Number Mapper allows you to change the data type string to a number. Usually used to denote value, for example, prices.
This guide will provide a sample of how you can use this mapper.
Usage
- Create a new Value mapper.
- Configure the accessor to access the attribute to the value that you want to map.
- Add a new mapper and choose Format: Number.
- Here you will get some fields to fill in.
- Decimals. The number of decimal digits. If 0, the decimal point is omitted from the return value.
- Decimal Point. The separator for the decimal point.
- Thousand Separator. The thousands separator. However, it’s possible to use this mapper without the thousand separator as it’s optional now.
Example
For example, you have the below data in an entity, and you need to format the number of the “price” property from 1299 to 1,299.00.
{
"sku": "SKU001",
"name": "T-Shirt 001",
"price": 1299
}
JavaScript
You can use this transformer to format it to the mentioned format.