bazaarvoice / jolt

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

How to perform String operations in Jolt #1120

Open venu1203 opened 2 years ago

venu1203 commented 2 years ago

Input:

{
    "Remarks":"COMMENTS:(87) Test Comments"
}

Expecting Output is below:

{
     "Remarks" : "C(87): TestComments"
     "Id" : 87

}

I want to replace COMMENTS:(87) string with C(87): and need to get 87 in brackets and print the same in separate attribute "Id". Can anyone help on this ?

le-zw commented 2 years ago

[ { "operation":"modify-overwrite-beta", "spec":{ "Remarks":"=substring(@(2,Remarks), 8, 26)" } }, { "operation":"modify-overwrite-beta", "spec":{ "Remarks":"=concat('C', @(2,Remarks))" } }, { "operation":"modify-default-beta", "spec":{ "Id":"=substring(@(2,Remarks), 3, 5)" } } ]