Skip to main content Skip to complementary content

Mapping fixed sets of values

Use the MapValues and ValueMapping functions to map a enumerated values from an input structure to different enumerated values in an output structure.

Information noteNote: This example uses the improved MapValues dialog box, which is available only if you have installed the R2024-04 Talend Studio monthly update or a later one delivered by Talend.

About this task

In this example, you have an input JSON file with an array of customers. Each customer contains three elements: id, name, and tier. The tier element has a fixed list of values: One, Two, and Three. In the output, you want a similar structure, but with status instead of tier, and with a different list of values: Platinum, Gold, and Silver. You need to map the tier values to the correct status values.
You can use the following JSON sample to create your input structure:
{
    "customers": [
        {
            "id": "abc-123",
            "name": "John Doe",
            "tier": "Two"
        },
        {
            "id": "def-456",
            "name": "Jane Smith",
            "tier": "One"
        },
        {
            "id": "ghi-789",
            "name": "Emily Stone",
            "tier": "Three"
        }
    ]
}            
You can use the following JSON sample to create your output structure.
{
    "customers": [
        {
            "id": "",
            "name": "",
            "status": ""
        }
    ]
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!