Operations (sample payloads)

Main operations
Copy

Add key/value pairs
Copy

Adds key/value pairs from a list array to a source object as properties and returns a singular object. The source object can either be empty or populated with properties. The list array contains objects and each object will have the fields key and value.

Sample Input

1
{
2
"source": {
3
"existingKey": "existingValue"
4
},
5
"list": [
6
{
7
"key": "name",
8
"value": "John Doe"
9
},
10
{
11
"key": "age",
12
"value": 30
13
},
14
{
15
"key": "isEmployee",
16
"value": true
17
},
18
{
19
"key": "hobbies",
20
"value": [
21
"reading",
22
"swimming"
23
]
24
},
25
{
26
"key": "address",
27
"value": {
28
"street": "123 Main St",
29
"city": "Anytown",
30
"country": "USA"
31
}
32
}
33
]
34
}

Sample Output

1
{
2
"result": {
3
"existingKey": "existingValue",
4
"name": "John Doe",
5
"age": 30,
6
"isEmployee": true,
7
"hobbies": [
8
"reading",
9
"swimming"
10
],
11
"address": {
12
"street": "123 Main St",
13
"city": "Anytown",
14
"country": "USA"
15
}
16
}
17
}

Add value by key
Copy

Add a value to an object by its key.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30
5
},
6
"key": "email",
7
"value": "johndoe@example.com"
8
}

Sample Output

1
{
2
"result": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "johndoe@example.com"
6
}
7
}

Contains
Copy

Returns true if an object contains an assigned value, false otherwise.

Sample Input

1
{
2
"source": {
3
"user": {
4
"name": "John Doe",
5
"age": 30,
6
"address": {
7
"street": "123 Main St",
8
"city": "New York",
9
"country": "USA"
10
},
11
"email": "john.doe@example.com"
12
}
13
},
14
"key": "user.address.street"
15
}

Sample Output

1
{
2
"result": true
3
}

Delete key value pair
Copy

Delete a key value pair with a given key.

Sample Input

1
{
2
"source": {
3
"id": 123,
4
"user": {
5
"name": "John Doe",
6
"email": "john@example.com",
7
"address": {
8
"street": "123 Main St",
9
"city": "Anytown",
10
"country": "USA"
11
}
12
},
13
"status": "active"
14
},
15
"key": "user.address.street"
16
}

Sample Output

1
{
2
"result": {
3
"id": 123,
4
"user": {
5
"name": "John Doe",
6
"email": "john@example.com",
7
"address": {
8
"city": "Anytown",
9
"country": "USA"
10
}
11
},
12
"status": "active"
13
}
14
}

Enforce object structure
Copy

Define a JSON structure which the output object must adhere to. The output object will contain at least the defined structure along with any additional fields from the input.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "johndoe@example.com",
6
"address": {
7
"street": "123 Main St",
8
"city": "Anytown"
9
},
10
"hobbies": [
11
"reading",
12
"swimming"
13
]
14
},
15
"structure": {
16
"name": "",
17
"age": null,
18
"email": "",
19
"phone": "",
20
"address": {
21
"street": "",
22
"city": "",
23
"zipcode": ""
24
}
25
}
26
}

Sample Output

1
{
2
"result": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "johndoe@example.com",
6
"phone": null,
7
"address": {
8
"street": "123 Main St",
9
"city": "Anytown",
10
"zipcode": null
11
},
12
"hobbies": [
13
"reading",
14
"swimming"
15
]
16
}
17
}

Equals
Copy

Returns true if an object is exactly the same as another object, false otherwise.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"city": "New York"
6
},
7
"target": {
8
"name": "John Doe",
9
"age": 30,
10
"city": "New York"
11
}
12
}

Sample Output

1
{
2
"result": true
3
}

Find difference
Copy

Finds the difference between two objects and returns it.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"city": "New York",
6
"occupation": "Engineer"
7
},
8
"target": {
9
"name": "John Doe",
10
"age": 31,
11
"city": "Los Angeles",
12
"hobbies": [
13
"reading",
14
"swimming"
15
]
16
}
17
}

Sample Output

1
{
2
"source": {
3
"age": 30,
4
"city": "New York",
5
"occupation": "Engineer"
6
},
7
"target": {
8
"age": 31,
9
"city": "Los Angeles",
10
"hobbies": [
11
"reading",
12
"swimming"
13
]
14
}
15
}

Get value by key
Copy

Get a value from an object by its key.

Sample Input

1
{
2
"source": {
3
"user": {
4
"name": "John Doe",
5
"age": 30,
6
"address": {
7
"street": "123 Main St",
8
"city": "New York",
9
"country": "USA"
10
},
11
"hobbies": [
12
"reading",
13
"swimming",
14
"photography"
15
]
16
},
17
"company": "Acme Inc.",
18
"isActive": true
19
},
20
"key": "user.address.city",
21
"default": "Unknown"
22
}

Sample Output

1
{
2
"result": "New York"
3
}

Iterative transform
Copy

Given an object, iterate through its properties, and transform the associated keys and values accordingly.

Sample Input

1
{
2
"source": {
3
"firstName": "John",
4
"lastName": "Doe",
5
"age": 30,
6
"email_address": "john.doe@example.com",
7
"phone_number": "123-456-7890"
8
},
9
"key_transform": "snake_case",
10
"value_transform": "upper_case"
11
}

Sample Output

1
{
2
"source": {
3
"firstName": "John",
4
"lastName": "Doe",
5
"age": 30,
6
"email_address": "john.doe@example.com",
7
"phone_number": "123-456-7890"
8
},
9
"target": {
10
"first_name": "JOHN",
11
"last_name": "DOE",
12
"age": "30",
13
"email_address": "JOHN.DOE@EXAMPLE.COM",
14
"phone_number": "123-456-7890"
15
}
16
}

JSON parse
Copy

Take a JSON string/text and parse it into an object.

Sample Input

1
{
2
"source": "{\"name\":\"John Doe\",\"age\":30,\"city\":\"New York\",\"isStudent\":false,\"hobbies\":[\"reading\",\"swimming\",\"photography\"]}"
3
}

Sample Output

1
{
2
"result": {
3
"name": "John Doe",
4
"age": 30,
5
"city": "New York",
6
"isStudent": false,
7
"hobbies": [
8
"reading",
9
"swimming",
10
"photography"
11
]
12
}
13
}

JSON stringify
Copy

Take an object and transform it into a JSON string.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "johndoe@example.com",
6
"isSubscribed": true,
7
"hobbies": [
8
"reading",
9
"swimming",
10
"cycling"
11
],
12
"address": {
13
"street": "123 Main St",
14
"city": "Anytown",
15
"country": "USA"
16
}
17
}
18
}

Sample Output

1
{
2
"result": "{\"name\":\"John Doe\",\"age\":30,\"email\":\"johndoe@example.com\",\"isSubscribed\":true,\"hobbies\":[\"reading\",\"swimming\",\"cycling\"],\"address\":{\"street\":\"123 Main St\",\"city\":\"Anytown\",\"country\":\"USA\"}}"
3
}

Map keys
Copy

Given an object, transform the given property key names.

Sample Input

1
{
2
"source": {
3
"firstName": "John",
4
"lastName": "Doe",
5
"emailAddress": "john.doe@example.com",
6
"phoneNumber": "123-456-7890"
7
},
8
"key_transformations": [
9
{
10
"source_key": "firstName",
11
"target_key": "first_name"
12
},
13
{
14
"source_key": "lastName",
15
"target_key": "last_name"
16
},
17
{
18
"source_key": "emailAddress",
19
"target_key": "email"
20
},
21
{
22
"source_key": "phoneNumber",
23
"target_key": "phone"
24
}
25
]
26
}

Sample Output

1
{
2
"result": {
3
"first_name": "John",
4
"last_name": "Doe",
5
"email": "john.doe@example.com",
6
"phone": "123-456-7890"
7
}
8
}

Merge two objects
Copy

Merge two objects. If there is any property specified in both objects, the one specified in the first (source object) will be used.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "john@example.com"
6
},
7
"target": {
8
"age": 35,
9
"occupation": "Developer",
10
"city": "New York"
11
}
12
}

Sample Output

1
{
2
"result": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "john@example.com",
6
"occupation": "Developer",
7
"city": "New York"
8
}
9
}

Pick values by keys
Copy

Pick values from an object by its keys.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "johndoe@example.com",
6
"address": "123 Main St",
7
"city": "New York",
8
"country": "USA"
9
},
10
"keys_to_pick": [
11
"name",
12
"email",
13
"country"
14
]
15
}

Sample Output

1
{
2
"result": {
3
"name": "John Doe",
4
"email": "johndoe@example.com",
5
"country": "USA"
6
}
7
}

Properties exist
Copy

Check if a list of properties are found in an object. If any are not found, a list of the properties not found is returned.

Sample Input

1
{
2
"source": {
3
"user": {
4
"name": "John Doe",
5
"email": "john.doe@example.com",
6
"age": 30
7
},
8
"order": {
9
"id": "ORD-123",
10
"total": 99.99
11
}
12
},
13
"property_keys": [
14
"user.name",
15
"user.email",
16
"user.phone",
17
"order.id",
18
"order.date"
19
]
20
}

Sample Output

1
{
2
"found": [
3
"user.name",
4
"user.email",
5
"order.id"
6
],
7
"not_found": [
8
"user.phone",
9
"order.date"
10
],
11
"found_all": false
12
}

Remove null values
Copy

Remove Null and/or empty String values from an object.

Sample Input

1
{
2
"source": {
3
"name": "John Doe",
4
"age": 30,
5
"email": "",
6
"phone": null,
7
"address": {
8
"street": "123 Main St",
9
"city": "New York",
10
"state": null,
11
"zip": ""
12
},
13
"hobbies": [
14
"reading",
15
null,
16
"swimming"
17
]
18
},
19
"values_to_remove": "both"
20
}

Sample Output

1
{
2
"result": {
3
"name": "John Doe",
4
"age": 30,
5
"address": {
6
"street": "123 Main St",
7
"city": "New York"
8
},
9
"hobbies": [
10
"reading",
11
"swimming"
12
]
13
}
14
}