I've a JSON like this:
{
"result":{
"BidModifiers":[
{
"AdGroupId":5462325568,
"Level":"AD_GROUP",
"Type":"DESKTOP_ADJUSTMENT",
"DesktopAdjustment":{
"BidModifier":0
}
},
{
"AdGroupId":5462325568,
"Level":"AD_GROUP",
"Type":"SMART_TV_ADJUSTMENT",
"SmartTvAdjustment":{
"BidModifier":200,
"Age":[
18,
19,
20,
21
]
}
},
{
"AdGroupId":5462325568,
"Level":"AD_GROUP",
"Type":"RETARGETING_ADJUSTMENT",
"RetargetingAdjustment":{
"RetargetingConditionId":540
}
}
]
}
}
Inside BidModifiers
array can be different Types
with different keys. But their name always ends with Adjustment
: DesktopAdjustment
, SmartTvAdjustment
, etc. I need to grab all from these keys and also add Type
. I expect this json:
[
{
"Type":"DESKTOP_ADJUSTMENT",
"DesktopAdjustment":{
"BidModifier":0
}
},
{
"Type":"SMART_TV_ADJUSTMENT",
"SmartTvAdjustment":{
"BidModifier":200,
"Age":[
18,
19,
20,
21
]
}
},
{
"Type":"RETARGETING_ADJUSTMENT",
"RetargetingAdjustment":{
"RetargetingConditionId":540
}
}
]
I tried with:
[
{
"operation": "shift",
"spec": {
"result": {
"BidModifiers": {
"*": {
"Type": "[&1].Type",
"*Adjustment": {
"*": "[#1].&"
}
}
}
}
}
}
]
But it returns invalid result
You just need this shift transformation spec :
[
{
"operation": "shift",
"spec": {
"result": {
"BidModifiers": {
"*": {
"Type|*Adjustment": "[&1].&"
}
}
}
}
}
]
eg. apply matching from the common level for all those attributes