Closed spnathan-ce closed 8 months ago
There are several solutions, but this is probably the easiest to understand:
[
{ // extract token value
"operation": "shift",
"spec": {
"data": {
"*": {
"key": {
"token": {
"@(2,value)": "tokenValue"
}
}
}
}
}
},
{ // split on #
"operation": "modify-overwrite-beta",
"spec": {
"tokenValue": "=split('#',@0)"
}
},
{ // get first element of array
"operation": "modify-overwrite-beta",
"spec": {
"tokenValue": "=firstElement"
}
}
]
Thanks a lot @gbouget
Resolved
I need help in Splitting a String and get the 0th index, the String is contained in a list of objects. The below are the details
Input JSON:
{ "data": [ { "key": "name", "value": "Nathan" }, { "key": "token", "value": "123#456#789" } ] }
Rule I am using:
[ { "operation": "modify-overwrite-beta", "spec": { "data": { "*": { "key": { "token": { "list": "=split('#',@(2,value))" } } } } } }, { "operation": "shift", "spec": { "data": { "*": { // I need in help in accessing the list value I created in the modify-overwrite-beta operation } } } } ]
Expected output: { "tokenValue":"123" }
Please help on this