I have a JSON payload and I would like to add the software architecture designation (x86 or x64) as a new property called architecture.
{
"name": "T15P-GEN3",
"software": {
"x86": [
{
"name": "AAA",
"version": "1.3.4",
"uninstall": "MsiExec.exe /I{3A969900-CAD5-4FB8-B5D1-1F8D9028C6AA}"
},
{
"name": "BBB",
"version": "1.1.2",
"uninstall": "MsiExec.exe /I{102C3B71-22B5-4484-8D1F-1C859CA6EE63}"
},
{
"name": "CCC",
"version": "1.1.4",
"uninstall": "MsiExec.exe /I{D65355E4-021A-4B0C-B9A4-9D90F8C0D106}"
}
],
"x64": [
{
"name": "AAAA (x64)",
"version": "24.01",
"uninstall": "'C:\\Program Files\\AAAA\\Uninstall.exe'"
},
{
"name": "BBBB (2023)",
"version": "5.5.5.2811",
"uninstall": "MsiExec.exe /I{92EC01FE-5C8D-4D03-B8D1-F0A2AEF14EB3}"
},
{
"name": "CCCC",
"version": "",
"uninstall": "C:\\Program Files\\CCCC\\CCCC_x64.exe -?uninstall"
}
]
}
}
Desired output would be:
{
"name": "T15P-GEN3",
"software": {
"x86": [
{
"name": "AAA",
"version": "1.3.4",
"uninstall": "MsiExec.exe /I{3A969900-CAD5-4FB8-B5D1-1F8D9028C6AA}",
"architecture": "x86"
},
{
"name": "BBB",
"version": "1.1.2",
"uninstall": "MsiExec.exe /I{102C3B71-22B5-4484-8D1F-1C859CA6EE63}",
"architecture": "x86"
},
{
"name": "CCC",
"version": "1.1.4",
"uninstall": "MsiExec.exe /I{D65355E4-021A-4B0C-B9A4-9D90F8C0D106}",
"architecture": "x86"
}
],
"x64": [
{
"name": "AAAA (x64)",
"version": "24.01",
"uninstall": "'C:\\Program Files\\AAAA\\Uninstall.exe'",
"architecture": "x64"
},
{
"name": "BBBB (2023)",
"version": "5.5.5.2811",
"uninstall": "MsiExec.exe /I{92EC01FE-5C8D-4D03-B8D1-F0A2AEF14EB3}",
"architecture": "x64"
},
{
"name": "CCCC",
"version": "",
"uninstall": "C:\\Program Files\\CCCC\\CCCC_x64.exe -?uninstall",
"architecture": "x64"
}
]
}
}
I have tried experimenting based on the following posts JOLT add object name into body and JOLT add property based on name of another property but cannot get it to work the way I want it.
{
"operation": "shift",
"spec": {
"software": {
"*": {
"*": {
"@": "&3[].&",
"$": "&3[].&.architecture"
}
}
}
}
}
I have just started working with Jolt transformations, but this one is a bit too difficult for me to solve.
You can use
where