Transformer: Add values to list elements
Discover more about Transformer and how to add values to list elements on the Digibee Integration Platform.
Was this helpful?
Discover more about Transformer and how to add values to list elements on the Digibee Integration Platform.
Was this helpful?
Was this helpful?
{
"happy": "true",
"statistics": [
{
"id": "A",
"min": "2.0",
"max": "10.0",
"avg": "7.9"
},
{
"min": "6",
"max": "6",
"avg": "6"
},
{
"id": "C"
}
]
}
[
{
"operation": "modify-overwrite-beta",
// To add the value only if it does not exist, change the operation to "modify-default-beta"
"spec": {
"statistics": {
"*": {
"newValue": "test123"
}
}
}
}
]
{
"happy": "true",
"statistics" : [ {
"id" : "A",
"min" : "2.0",
"max" : "10.0",
"avg" : "7.9",
"newValue" : "test123"
}, {
"min" : "6",
"max" : "6",
"avg" : "6",
"newValue" : "test123"
}, {
"id" : "C",
"newValue" : "test123"
} ]
}
To add a dynamic value, use the following Transformer Spec structure:
[
{
"operation": "modify-overwrite-beta",
// To add the value only if it does not exist, change the operation to "modify-default-beta"
"spec": {
"statistics": {
"*": {
"newValue": "@(3,happy)"
}
}
}
}
]
Note: in the above example, the number "3" indicates the number of levels that must be uploaded to access the JSON object. To better understand it, see the example below:
{
"levelA": {
"levelB": {
"happy": "true"
}
},
"levelX": {
"statistics": [
{
"id": "A",
"min": "2.0",
"max": "10.0",
"avg": "7.9"
},
{
"min": "6",
"max": "6",
"avg": "6"
},
{
"id": "C"
}
]
}
}
[
{
"operation": "modify-overwrite-beta",
"spec": {
"nivelX": {
"statistics": {
// the item "*" (all list elements, it is also considered a level)
"*": {
"newValue": "@(5,levelA.levelB.happy)"
}
}
}
}
}
]