I need to write jolt spec for this transformation
Input :
{
"key": [
"a",
"b",
"c",
"",
"d",
"e",
"f",
""
]
}
Output should be :
{
"key": [
"a",
"b",
"c",
"d",
"e",
"f"
]
}
What would be jolt spec for above transformation , basically removing all empty string from array ?
The trick is to match the ""
values with the value null
such as "": null
:
[
{
"operation": "shift",
"spec": {
"*": { // the level of the array "key"
"*": { // the level of the indexes of the array
"": null,
"*": { // the values other than ""s
"@1": "&3" // @1 replicates the innermost values as a whole
// while matches &3 which copies the literal "key"
}
}
}
}
}
]
the demo on the site https://jolt-demo.appspot.com/ is :