Operations (sample payloads)

Main operations
Copy

Map keys
Copy

Given an object, maps values to new keys. Returns a new object with the new keys.

Sample Input

1
{
2
"object1": {
3
"firstName": "John",
4
"lastName": "Doe",
5
"email": "john.doe@example.com",
6
"age": 30
7
},
8
"mappings": [
9
{
10
"from": "firstName",
11
"to": "given_name"
12
},
13
{
14
"from": "lastName",
15
"to": "family_name"
16
},
17
{
18
"from": "email",
19
"to": "contact_email"
20
}
21
]
22
}

Sample Output

1
{
2
"given_name": "John",
3
"family_name": "Doe",
4
"contact_email": "john.doe@example.com"
5
}

Map list to object
Copy

Map an array of key value objects to a single object.

Sample Input

1
{
2
"data": [
3
{
4
"key": "firstName",
5
"value": "John"
6
},
7
{
8
"key": "lastName",
9
"value": "Doe"
10
},
11
{
12
"key": "age",
13
"value": 30
14
},
15
{
16
"key": "email",
17
"value": "john.doe@example.com"
18
}
19
],
20
"field_key": "key",
21
"field_value": "value"
22
}

Sample Output

1
{
2
"firstName": "John",
3
"lastName": "Doe",
4
"age": 30,
5
"email": "john.doe@example.com"
6
}

Map multiple values between objects
Copy

Map values between objects. Returns a new object with the new properties.

Sample Input

1
{
2
"object1": {
3
"firstName": "John",
4
"lastName": "Doe",
5
"age": 30,
6
"email": "john.doe@example.com"
7
},
8
"object2": {
9
"name": "Jane Smith",
10
"userAge": 28,
11
"contactEmail": "jane.smith@example.com",
12
"occupation": "Software Engineer"
13
},
14
"mappings": [
15
{
16
"from": "firstName",
17
"to": "name"
18
},
19
{
20
"from": "age",
21
"to": "userAge"
22
},
23
{
24
"from": "email",
25
"to": "contactEmail"
26
}
27
]
28
}

Sample Output

1
{
2
"firstName": "Jane Smith",
3
"lastName": "Doe",
4
"age": 28,
5
"email": "jane.smith@example.com"
6
}

Map objects
Copy

Map object fields to new keys.

Sample Input

1
{
2
"data": [
3
{
4
"firstName": "John",
5
"lastName": "Doe",
6
"age": 30,
7
"email": "john.doe@example.com",
8
"address": {
9
"street": "123 Main St",
10
"city": "Anytown",
11
"country": "USA"
12
}
13
},
14
{
15
"firstName": "Jane",
16
"lastName": "Smith",
17
"age": 28,
18
"email": "jane.smith@example.com",
19
"address": {
20
"street": "456 Elm St",
21
"city": "Othertown",
22
"country": "Canada"
23
}
24
}
25
],
26
"mapping": {
27
"firstName": "given_name",
28
"lastName": "family_name",
29
"age": "years_old",
30
"email": "contact_email",
31
"address.street": "home_address.street_name",
32
"address.city": "home_address.city_name",
33
"address.country": "home_address.country_name"
34
},
35
"include_unmapped": true,
36
"include_nulls": false,
37
"include_empty_strings": false,
38
"required_fields": [
39
"given_name",
40
"family_name",
41
"contact_email"
42
]
43
}

Sample Output

1
[
2
{
3
"given_name": "John",
4
"family_name": "Doe",
5
"years_old": 30,
6
"contact_email": "john.doe@example.com",
7
"home_address": {
8
"street_name": "123 Main St",
9
"city_name": "Anytown",
10
"country_name": "USA"
11
}
12
},
13
{
14
"given_name": "Jane",
15
"family_name": "Smith",
16
"years_old": 28,
17
"contact_email": "jane.smith@example.com",
18
"home_address": {
19
"street_name": "456 Elm St",
20
"city_name": "Othertown",
21
"country_name": "Canada"
22
}
23
}
24
]

Map objects to list
Copy

Map an object or an array of objects to an array of key value objects.

Sample Input

1
{
2
"data": [
3
{
4
"name": "John Doe",
5
"age": 30,
6
"city": "New York"
7
},
8
{
9
"name": "Jane Smith",
10
"age": 25,
11
"country": "Canada"
12
}
13
],
14
"field_key": "attribute",
15
"value_key": "data"
16
}

Sample Output

1
[
2
{
3
"attribute": "name",
4
"data": "John Doe"
5
},
6
{
7
"attribute": "age",
8
"data": 30
9
},
10
{
11
"attribute": "city",
12
"data": "New York"
13
},
14
{
15
"attribute": "name",
16
"data": "Jane Smith"
17
},
18
{
19
"attribute": "age",
20
"data": 25
21
},
22
{
23
"attribute": "country",
24
"data": "Canada"
25
}
26
]

Map one value
Copy

Given a value, map according to defined mappings. Returns the result of the mapping. If no mapping is defined for the value, returns the default value, otherwise returns null if no default is defined.

Sample Input

1
{
2
"mappings": [
3
{
4
"from": "red",
5
"to": "apple"
6
},
7
{
8
"from": "yellow",
9
"to": "banana"
10
},
11
{
12
"from": "green",
13
"to": "kiwi"
14
}
15
],
16
"value": "yellow",
17
"default_value": "unknown fruit"
18
}

Sample Output

1
{
2
"result": "banana"
3
}

Map values
Copy

Given an object, or an array of objects, maps one or more values to new value(s). You may limit the mapping to specific object keys. Returns a new object (or array) retaining the original structure but with mapped values.

Sample Input

1
{
2
"input": [
3
{
4
"name": "John Doe",
5
"age": 30,
6
"status": "active",
7
"subscription": "basic"
8
},
9
{
10
"name": "Jane Smith",
11
"age": 25,
12
"status": "inactive",
13
"subscription": "premium"
14
}
15
],
16
"mappings": [
17
{
18
"from": "active",
19
"to": true,
20
"keys": [
21
"status"
22
]
23
},
24
{
25
"from": "inactive",
26
"to": false,
27
"keys": [
28
"status"
29
]
30
},
31
{
32
"from": "basic",
33
"to": "tier_1",
34
"keys": [
35
"subscription"
36
]
37
},
38
{
39
"from": "premium",
40
"to": "tier_2",
41
"keys": [
42
"subscription"
43
]
44
}
45
]
46
}

Sample Output

1
[
2
{
3
"name": "John Doe",
4
"age": 30,
5
"status": true,
6
"subscription": "tier_1"
7
},
8
{
9
"name": "Jane Smith",
10
"age": 25,
11
"status": false,
12
"subscription": "tier_2"
13
}
14
]