bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.55k stars 330 forks source link

Input JSON lost when doing a date concat #1252

Closed mordfustang00 closed 5 months ago

mordfustang00 commented 5 months ago

Good Day. I would like to seek for assistance to achieve the following scenario:

Input would be:

{ "CarStat": { "mileage": { "value": 1000 } }, "header": { "Date": "Fri, 29 Mar 2024 17:50:26 GMT", "Offset": "-7" } }

Output should be:

{ "CarStat" : { "mileage" : { "value" : 1000 } }, "header" : { "Date" : "20240329175026.000", "Offset" : "-7", "year" : "2024", "month" : "03", "day" : "29", "timeHH" : "17", "timeMM" : "50", "timeSS" : "26", "sss" : ".000" } }

But output looks like this:

{ "CarStat" : { "mileage" : { "value" : 1000 } }, "header" : { "Date" : "2024Mar29175026.000", "Offset" : "-7", "year" : "2024", "month" : "Mar", "day" : "29", "timeHH" : "17", "timeMM" : "50", "timeSS" : "26", "sss" : ".000" } }

This is the current spec:

[ { "operation": "modify-overwrite-beta", "spec": { "header": { "year": "=substring(@(1,Date), 12, 16)", "month": "=substring(@(1,Date), 8, 11)", "day": "=substring(@(1,Date), 5, 7)", "timeHH": "=substring(@(1,Date), 17, 19)", "timeMM": "=substring(@(1,Date), 20, 22)", "timeSS": "=substring(@(1,Date), 23, 25)", "sss": ".000" } } },

{ "operation": "shift", "spec": { "*": "&", "month": { "Mar": { "#03": "month" } } } }, { "operation": "modify-overwrite-beta", "spec": { "header": { "month": "=substring(@(1,Date), 4, 1)", "Date": "=concat(@(1,year),@(1,month),@(1,day),@(1,timeHH),@(1,timeMM),@(1,timeSS),@(1,sss))" } } } ]

Many Thanks.