I'm trying to do some data transformation using JOLT for Apache nifi but I'm running into some problem.
The sample input is:
{
"id": "1234"
}
The sample output is:
{
"$distinct_id": "1234"
}
My JOLT Specs:
[
{
"operation": "shift",
"spec": {
"id": "$distinct_id"
}
}
]
But i'm getting this error
Error running the Transform.
JOLT Chainr encountered an exception constructing Transform className:com.bazaarvoice.jolt.Shiftr at index:0.
DotNotation (write key) can not contain '*' or '$' : write key: root.$distinct_id
NOTE: the '$' is mandatory as it's my payload for mixpanel
If your aim is to get exact JSON stated in the sample output, then you can use
[
{
"operation": "shift",
"spec": {
"id": "\\$distinct_&" // btw, & replicates the current key "id"
}
}
]
It has a special meaning that is returning the key's value from the upper node.
This special character $ could be escaped through use of double backslashes.