I can't seem to figure out JOLT to the point of frustration..
I can bring all of the values into a single nested array with no issue, however I cannot add values to the root of the output.
Data:
[
{
"Q": "10",
"W": "0.5",
"O": "Oregon",
"Status": "Valid",
"Type": "SSD",
"Number": "Samsung1234",
"Total": "50",
"Category": "Drive"
},
{
"Q": "15",
"W": "0.5",
"O": "Seattle",
"Status": "Valid",
"Type": "SSD",
"Number": "PNY1234",
"Total": "100",
"Category": "Drive"
}
...
]
Current Spec:
[
{
"operation": "shift",
"spec": {
"*": "data.drives"
}
}
]
Which gives me the following structure:
{
"data" : {
"drives" : [ {
"Q" : "10",
"W" : "0.5",
"O" : "Oregon",
"Status" : "Valid",
"Type" : "SSD",
"Number" : "Samsung1234",
"Total" : "50",
"Category" : "Drive"
}, {
"Q" : "15",
"W" : "0.5",
"O" : "Seattle",
"Status" : "Valid",
"Type" : "SSD",
"Number" : "PNY1234",
"Total" : "100",
"Category" : "Drive"
} ]
}
...
}
What I need is:
{
"data": {
"Number": "Samsung1234",
"Category": "Drive",
"Type": "SSD",
"drives": [
{
"Q": "10",
"W": "0.5",
"O": "Oregon",
"Status": "Valid",
"Total": "50"
},
{
"Q": "15",
"W": "0.5",
"O": "Seattle",
"Status": "Valid",
"Total": "100"
}
]
}
...
}
Any help is greatly appreciated. Jolt remains mostly a mystery to me, I just can't wrap my head around it..
You can use the following transformation if the aim is to get the only the first
Number,CategoryandTypevalues :