Open arshad10244 opened 1 year ago
I think this is what you are trying to do (key look up) :-
spec :-
[
{
"operation": "shift",
"spec": {
"items": {
"a1b2xxxx": {
"*": "items.a1b2xxxx.&",
"attr": {
"*": {
"@": "items.a1b2xxxx.attr[].key"
}
}
},
"c2b2cxxxx": {
"*": "items.c2b2cxxxx.&",
"attr": {
"*": {
"@": "items.c2b2cxxxx.attr[].key"
}
}
}
},
"*": "&"
}
}
,
{
"operation": "shift",
"spec": {
"items": {
"a1b2xxxx": {
"*": "items.a1b2xxxx.&",
"attr": {
"*": {
"@(0,key)": {
"*": {
"@(6,codes.&)": "items.a1b2xxxx.attr.@(3,key)"
}
}
}
}
},
"c2b2cxxxx": {
"*": "items.c2b2cxxxx.&",
"attr": {
"*": {
"@(0,key)": {
"*": {
"@(6,codes.&)": "items.c2b2cxxxx.attr.@(3,key)"
}
}
}
}
}
},
"*": "&"
}
}
]
output JSON :-
{
"items" : {
"a1b2xxxx" : {
"name" : "item 1",
"attr" : {
"A" : {
"color" : "green"
},
"B" : {
"size" : "M"
},
"C" : {
"sku" : "NS"
}
}
},
"c2b2cxxxx" : {
"name" : "item 2",
"attr" : {
"D" : {
"stock" : 2
},
"E" : {
"some_key" : "some_value"
},
"F" : {
"foo" : "bar"
}
}
}
},
"codes" : {
"A" : {
"color" : "green"
},
"B" : {
"size" : "M"
},
"C" : {
"sku" : "NS"
},
"D" : {
"stock" : 2
},
"E" : {
"some_key" : "some_value"
},
"F" : {
"foo" : "bar"
}
}
}
Hi everyone,
I've spent quite a lot of time figuring it out but I'm stuck, i have a nested JSON and i want to enrich the values of "attr" with those matching the keys of "codes", please help :pray:
Here is my input :
This is the desired output :