问题
Am trying something very simple with Jolt transformation but struggling to get it to work.
If I have an input like:
{
"id": "54436001"
}
I want output to be:
{
"mediaId" : "54436001",
"events" : {
"mediaId" : "54436001"
}
}
Which is copying a value to two different attributes. I would be tempted to try spec like this to work, but obviously it doesn't because of duplicate key.
[
{
"operation": "shift",
"spec": {
"id": "mediaId",
"id": "events.mediaId"
}
}
]
Is this possible with Jolf transformation?
回答1:
Yes
Spec
[
{
"operation": "shift",
"spec": {
"id": ["mediaId", "events.mediaId"]
}
}
]
The idea is if you want shift to write a value to two locations in the output, use an array on the right hand side of the spec.
来源:https://stackoverflow.com/questions/41618761/with-jolt-json-transformation-is-it-possible-to-copy-a-value-into-two-different