Closed abhiupa087 closed 2 months ago
Hi,
I am trying to write a Jolt Spec for transforming below Input JSON to a provided Output JSON. Input JSON { "headers": { "SourceXPath": "ds_id:db_name:table_name" }, "value": { "content": [ { "entityName": "column_name_1", "data": [ "425 442 4000", "206 442 4000" ] }, { "entityName": "column_name_2", "data": [ "jacknjill@hill.com", "jillnjack@hill.com" ] } ] } }
{ "headers": { "SourceXPath": "ds_id:db_name:table_name" }, "value": { "content": [ { "entityName": "column_name_1", "data": [ "425 442 4000", "206 442 4000" ] }, { "entityName": "column_name_2", "data": [ "jacknjill@hill.com", "jillnjack@hill.com" ] } ] } }
Desired Output JSON [ { "entityName": "column_name_1", "data": [ "425 442 4000", "206 442 4000" ], "parentXpath": [ "ds_id", "db_name", "table_name" ] }, { "entityName": "column_name_2", "data": [ "jacknjill@hill.com", "jillnjack@hill.com" ], "parentXpath": [ "ds_id", "db_name", "table_name" ] } ]
[ { "entityName": "column_name_1", "data": [ "425 442 4000", "206 442 4000" ], "parentXpath": [ "ds_id", "db_name", "table_name" ] }, { "entityName": "column_name_2", "data": [ "jacknjill@hill.com", "jillnjack@hill.com" ], "parentXpath": [ "ds_id", "db_name", "table_name" ] } ]
I wrote below JOLT Spec for this. [ { "operation": "shift", "spec": { "headers": { "SourceXPath": { "@(2,SourceXPath)": "parentXpath" } }, "value": { "content": { "*": { "entityName": "[&1].entityName", "data": "[&1].data", "@(1,parentXpath)": "[&1].parentXpath" } } } } }, { "operation": "modify-overwrite-beta", "spec": { "parentXpath": "=split(':', @(1,parentXpath))" } }, { "operation": "shift", "spec": { "*": { "parentXpath": "[&1].parentXpath", "entityName": "[&1].entityName", "data": "[&1].data" } } } ]
[ { "operation": "shift", "spec": { "headers": { "SourceXPath": { "@(2,SourceXPath)": "parentXpath" } }, "value": { "content": { "*": { "entityName": "[&1].entityName", "data": "[&1].data", "@(1,parentXpath)": "[&1].parentXpath" } } } } }, { "operation": "modify-overwrite-beta", "spec": { "parentXpath": "=split(':', @(1,parentXpath))" } }, { "operation": "shift", "spec": { "*": { "parentXpath": "[&1].parentXpath", "entityName": "[&1].entityName", "data": "[&1].data" } } } ]
But it does not give me desired output, Can you please help and suggest what is wrong with this Jolt spec?
Does Jolt even support the split functionality?
Was able to solve this, Thanks.
Hi,
I am trying to write a Jolt Spec for transforming below Input JSON to a provided Output JSON. Input JSON
{ "headers": { "SourceXPath": "ds_id:db_name:table_name" }, "value": { "content": [ { "entityName": "column_name_1", "data": [ "425 442 4000", "206 442 4000" ] }, { "entityName": "column_name_2", "data": [ "jacknjill@hill.com", "jillnjack@hill.com" ] } ] } }
Desired Output JSON
[ { "entityName": "column_name_1", "data": [ "425 442 4000", "206 442 4000" ], "parentXpath": [ "ds_id", "db_name", "table_name" ] }, { "entityName": "column_name_2", "data": [ "jacknjill@hill.com", "jillnjack@hill.com" ], "parentXpath": [ "ds_id", "db_name", "table_name" ] } ]
I wrote below JOLT Spec for this.
[ { "operation": "shift", "spec": { "headers": { "SourceXPath": { "@(2,SourceXPath)": "parentXpath" } }, "value": { "content": { "*": { "entityName": "[&1].entityName", "data": "[&1].data", "@(1,parentXpath)": "[&1].parentXpath" } } } } }, { "operation": "modify-overwrite-beta", "spec": { "parentXpath": "=split(':', @(1,parentXpath))" } }, { "operation": "shift", "spec": { "*": { "parentXpath": "[&1].parentXpath", "entityName": "[&1].entityName", "data": "[&1].data" } } } ]
But it does not give me desired output, Can you please help and suggest what is wrong with this Jolt spec?