Reputation: 49
how to convert the following data
{
"name" : "abcd",
"middleName" : "srivastav"
}
into
{
"name" : "abcd",
"middleName" : "srivastav"
"id" : "abcd"
}
by using a jolt transform such that the id
and the name
are within the same object as the expected output.
Upvotes: 0
Views: 411
Reputation: 545
modify-default-beta or default operations will work for this :
[
{
"operation": "modify-default-beta",
"spec": {
"id": "abcd"
}
}
]
Upvotes: 1
Reputation: 65408
One option is to replicate the value of name
through use of "@(0,name)":
while keeping the current attributes by "*": "&"
notation within a shift transformation such as
[
{
"operation": "shift",
"spec": {
"*": "&",
"@(0,name)": "id"
}
}
]
the demo on the site http://jolt-demo.appspot.com/ is
or another option is to use a modify(overwrite/default) transformation to dynamically replicate the value of name
attribute for id
such as
[
{
"operation": "modify-overwrite-beta",
"spec": {
"id": "@(1,name)"
}
}
]
the second demo is
Upvotes: 0