Input Json Object
{
"Customer": {
"CustomerName": "John Miller",
"CustomerType": "Banker",
"Attribute1": "",
"Attribute2": "",
"Attribute3": "",
"Attribute4": "",
"Contacts": [
{
"ContactIdentifier": "Contact1",
"Attribute1": "",
"Attribute2": "",
"Attribute3": "",
"Attribute4": "",
"Addresses": [
{
"AddressIdentifier": null,
"AddressLine1": "a1",
"AddressLine2": "b1",
"AddressLine3": "c1",
"Attribute1": "d1",
"Attribute2": "e1"
},
{
"AddressIdentifier": "2",
"AddressLine1": "a2",
"AddressLine2": "b2",
"AddressLine3": "c2",
"Attribute1": "d2",
"Attribute2": "e2"
}
]
},
{
"ContactIdentifier": "Contact2",
"Attribute1": "",
"Attribute2": "",
"Attribute3": "",
"Attribute4": "",
"Addresses": [
{
"AddressIdentifier": "11",
"AddressLine1": "a11",
"AddressLine2": "b11",
"AddressLine3": "c11",
"Attribute1": "d11",
"Attribute2": "e1"
},
{
"AddressIdentifier": "21",
"AddressLine1": "a21",
"AddressLine2": "b21",
"AddressLine3": "c21",
"Attribute1": "d21",
"Attribute2": "e21"
}
]
}
]
}
}
Expected output
{
"Customer": {
"CustomerName": "John Miller",
"CustomerType": "Banker",
"Contacts": [
{
"ContactIdentifier": "Contact1",
"Addresses": [
{
"AddressIdentifier": null,
"AddressLine1": "a1",
"AddressLine2": "b1",
"AddressLine3": "c1"
},
{
"AddressIdentifier": "2",
"AddressLine1": "a2",
"AddressLine2": "b2",
"AddressLine3": "c2"
}
]
},
{
"ContactIdentifier": "Contact2",
"Addresses": [
{
"AddressIdentifier": "11",
"AddressLine1": "a11",
"AddressLine2": "b11",
"AddressLine3": "c11"
},
{
"AddressIdentifier": "21",
"AddressLine1": "a21",
"AddressLine2": "b21",
"AddressLine3": "c21"
}
]
}
]
}
}
I'm trying to use jolt shift operation but I think I am missing something. I am not able to replicate the array of JSON object. Is there any other way of iterating the array of object, by using some other wildcard operator. Here I don't want to use remove operation as the object at the contact level is too much, removing one by one does not sound cool.
Any help will be appreciated.
Thanks in advance
[
{
"operation": "shift",
"spec": {
"Customer": {
"CustomerName": "CustomerName",
"CustomerType": "CustomerType",
"Contacts": {
"*": {
"ContactIdentifier": "Contacts[#].ContactIdentifier",
"Addresses": {
"*": {
"AddressIdentifier": "Contacts[#].Addresses[#].AddressIdentifier",
"AddressLine*": "Contacts[#].Addresses[#].&"
}
}
}
}
}
}
}
]