I'm facing issue while adding new Items to an Array. I want to add new Items in address array. any help would be appreciate. Thanks in advance:
This is my code:
input.json
{
"lines": [
{
"movement": {
"source": {
"node": "Org_Node",
"address": {
"addressLine1": "abc",
"addressLine2": "def",
"addressLine3": "eg",
"addressLine4": "abc123"
},
"recipient": {
"firstName": "Ravi",
"middleName": "",
"lastName": "krishna"
},
"contactInformation": {
"mobileNo": "9687568965"
}
}
}
}
]
}
In output I want to add city& state: Expected output is:
{
"address" : {
"address1" : "abc",
"address2" : "def",
"address3" : "eg",
"address4" : "abc123",
"city":"ATP",
"state":"AP"
},
"recipient" : {
"firstName" : "Ravi",
"middleName" : "",
"lastName" : "krishna"
},
"contactInformation" : {
"mobileNo" : "5036412733"
}
}
I wrote following spec file to get my desired output,Please let me know where i have to modify I'm new to JOLT. spec.json file:
[{
"operation": "shift",
"spec": {
"lines": {
"*": {
"movement": {
"source": {
"address": {
"addressLine*": "[#5].&1.address&(0,1)",
"*": "[#5].&1.&"
},
"recipient": {
"*": "[#5].&1.&"
},
"contactInformation": {
"*": "[#5].&1.&"
}
}
}
}
}
}
}]