I am new to JOLT transformation, can someone help me in transforming the Input JSON to the desired output?
Input JSON:
[
{
"product_id": 1,
"product_description": "Product 1 details",
"billing_details": {
"product_id": 1,
"billing_description": "Product 1 billing Details"
},
"product_part_desc": {
"id": 1,
"part_description": "product 1 part description"
}
},
{
"product_id": 2,
"product_description": "Product 2 details",
"billing_details": {
"product_id": 1,
"billing_description": "Product 2 billing Details"
},
"product_part_desc": {
"id": 1,
"part_description": "product 2 part description"
}
}
]
Tried Specification:
[
{
"operation": "shift",
"spec": {
"*": {
"product_id": "[&1].id",
"product_description": "[&1].description",
"billing_details": {
"billing_description": "[&2].bill_desc"
},
"*": "&"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": {
"product_part_desc": "=toString(@(1,product_part_desc))"
}
}
}
]
Expected output:
[
{
"id": 1,
"product_description": "Product 1 details",
"billing_description": "Product 1 billing Details",
"product_part_desc": "{id=1, part_description=product 1 part description}"
},
{
"product_id": 2,
"product_description": "Product 2 details",
"billing_description": "Product 2 billing Details",
"product_part_desc": "{id=1, part_description=product 2 part description}"
}
]
2
Answers
You can use this spec:
You can change the keys as you want in the above code.
You can use:
product_part_desc
attribute@billing_details.billing_description
identifier along with a shift transformation spec to getbilling_description
attributeas result: