Reputation: 422
I was trying to do a JOLT Transform,but I'm facing some difficulties in writing the spec for the same. I want to move some json elements from one list to another.
INPUT JSON
{
"billingsystem": {
"request": {
"profile": {
"identification_details": [
{
"identification_type": "1",
"identification_number": "4321221",
"id_issue_date": "11/11/2014",
"id_expiry_date": "11/11/2040",
"issuer_id": "vx",
"comment": "other"
}
],
"addresses": [
{
"language_id": "1",
"subscriber_level": "0",
"address_type": "0",
"addr_line1": "13 B, Sea View",
"addr_line2": "3rd Cross",
"addr_line3": "Chicago",
"addr_line4": "Illinois",
"addr_line5": "60601",
"country_id": "1"
}
]
}
}
}
}
i want to change this to given output json. I need a spec through which i can solve the issue. Need a spec that deals with the
OUTPUT JSON
{
"billingsystem": {
"request": {
"profile": {
"identification_details": [
{
"identification_type": "1",
"identification_number": "4321221",
"id_issue_date": "11/11/2014",
"id_expiry_date": "11/11/2040",
"issuer_id": "vx",
"comment": "other",
"addr_line3": "Chicago",
"addr_line4": "Illinois",
"addr_line5": "60601",
"country_id": "1"
}
],
"addresses": [
{
"language_id": "1",
"subscriber_level": "0",
"address_type": "0",
"addr_line1": "13 B, Sea View",
"addr_line2": "3rd Cross",
}
]
}
}
}
}
Upvotes: 0
Views: 581
Reputation: 26
the most important thing when you working with arrays(in jolt) indexes from where to where you want to shift the parameters and also knowing about "@,*,(index)" it will help you to come out from there
solution - spec :
[
{
"operation": "shift",
"spec": {
"billingsystem": {
"request": {
"profile": {
"addresses": {
"*": {
"language_id": "request.profile.addresses[&1].language_id",
"subscriber_level": "request.profile.addresses[&1].subscriber_level",
"address_type": "request.profile.addresses[&1].address_type",
"addr_line1": "request.profile.addresses[&1].addr_line1",
"addr_line2": "request.profile.addresses[&1].addr_line2"
}
},
"identification_details": {
"*": {
"identification_type": "request.profile.identification_details[&1].identification_type",
"identification_number": "request.profile.identification_details[&1].identification_number",
"id_issue_date": "request.profile.identification_details[&1].id_issue_date",
"id_expiry_date": "request.profile.identification_details[&1].id_issue_date",
"issuer_id": "request.profile.identification_details[&1].id_expiry_date",
"comment": "request.profile.identification_details[&1].comment",
"@(2,addresses[&].addr_line3)": "request.profile.identification_details[&1].addr_line3",
"@(2,addresses[&].addr_line4)": "request.profile.identification_details[&1].addr_line4",
"@(2,addresses[&].addr_line5)": "request.profile.identification_details[&1].addr_line5"
}
}
}
}
}
}
}
]
Upvotes: 1