Skip to main content Skip to complementary content

Mapping fixed sets of values

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

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 – please let us know!