Need help on writing JOLT spec :
Input sample:
{
"key": [
{
"sku": "015110530",
"location": "0635"
}
],
"value": [
{
"timestamp": 20230515094712,
"supplies": [
{
"stock_type": "C",
"requirement_category": "A06100021"
},
{
"stock_type": "B",
"requirement_category": "A06100022"
}
]
}
]
}
Output required:
[
{
"sku": "015110530",
"location": "0635",
"stock_type": "C",
"requirement_category": "A06100021"
},
{
"sku": "015110530",
"location": "0635",
"stock_type": "B",
"requirement_category": "A06100022"
}
]
could any one please help on the spec?
Tried below spec but only first array element is getting added with "key" attributes
[
{
"operation": "shift",
"spec": {
"key": {
"*": {
"sku": "[#2].sku",
"location": "[#2].location"
}
},
"value": {
"*": {
"supplies": {
"*": {
"stock_type": "[#2].stock_type",
"requirement_category": "[#2].requirement_category"
}
}
}
}
}
}
]
Any suggestion or spec would be much appreciated.
Thanks
Mahendra
2
Answers
I am able to get the desired output when I made "key" as single record instead of array :
One option is to make the shift transformation spec more dynamic by using
the demo on the site http://jolt-demo.appspot.com/ is