I need to transform a JSON structure by using a JOLT spec. I use https://jolt-demo.appspot.com to test the following below.
I can also run the OUTPUT through another JOLT Spec and then retrieve the JSON Output that I require, but I still have no idea what the JOLT spec should look like, I have looked at examples and didn't get any closer as to what is mentioned above.
Input -> Transform -> Output
Here is the INPUT JSON
{
"result": 0,
"companys": [
{
"id": 3,
"pId": 322,
"nm": "Balfin Trading (PTY) LTD"
},
{
"id": 25,
"pId": 0,
"nm": "FootCam"
}
],
"vehicles": [
{
"id": 487,
"desc": null,
"ic": 2,
"nm": "GCS001",
"pnm": null,
"dl": [
{
"id": "60335",
"ic": 0,
"us": null,
"md": 361,
"tn": "",
"vt": null,
"io": "",
"isb": null,
"sim": "0726168807",
"cc": 4,
"dId": null,
"sdc": null,
"pid": 83,
"st": null,
"tc": 0,
"cn": "ROAD,CAB,R SIDE VIEW,L SIDE VIEW",
"nflt": null
}
],
"adt": null,
"pvg": null,
"djb": null,
"etm": null,
"pid": 83,
"phone": null,
"abbr": null,
"vtp": null,
"st": null,
"dt": null,
"dn": null,
"linesOperation": null
},
{
"id": 486,
"desc": null,
"ic": 2,
"nm": "GCS002",
"pnm": null,
"dl": [
{
"id": "60334",
"ic": 0,
"us": null,
"md": 361,
"tn": "",
"vt": null,
"io": "",
"isb": null,
"sim": "0767024106",
"cc": 4,
"dId": null,
"sdc": null,
"pid": 83,
"st": null,
"tc": 0,
"cn": "ROAD,CAB,R SIDE,L SIDE",
"nflt": null
}
],
"adt": null,
"pvg": null,
"djb": null,
"etm": null,
"pid": 83,
"phone": null,
"abbr": null,
"vtp": null,
"st": null,
"dt": null,
"dn": null,
"linesOperation": null
},
{
"id": 491,
"desc": null,
"ic": 2,
"nm": "GCS003",
"pnm": null,
"dl": [
{
"id": "60294",
"ic": 0,
"us": null,
"md": 361,
"tn": "",
"vt": null,
"io": "",
"isb": null,
"sim": "0795732047",
"cc": 4,
"dId": null,
"sdc": null,
"pid": 83,
"st": null,
"tc": 0,
"cn": "ROAD,CAB,R SIDE,L SIDE",
"nflt": null
}
],
"adt": null,
"pvg": null,
"djb": null,
"etm": null,
"pid": 83,
"phone": null,
"abbr": null,
"vtp": null,
"st": null,
"dt": null,
"dn": null,
"linesOperation": null
}
]
}
This is the JOLT SPEC I currently have
[
{
"operation": "shift",
"spec": {
"vehicles": {
"*": {
"nm": "name",
"dl": {
"*": {
"id": "deviceID"
}
}
}
}
}
}
]
Which give the following OUTPUT
{
"name" : [ "GCS001", "GCS002", "GCS003" ],
"deviceID" : [ "60335", "60334", "60294" ]
}
INSTEAD I REQUIRE THE OUTPUT TO BE
[{
"name" : "GCS001",
"deviceID" : "60335"
},
{
"name" : "GCS002",
"deviceID" : "60334"
},
{
"name" : "GCGCS003S001",
"deviceID" : "60294"
}]