I have start writing a jolt transformation, and getting challenge to match the word from the object value.
input json
{
"application" : "android",
"issue" : "FoundCriticalBug",
}
now if the value in key "issue" is critical then print bug is "critical" else the value may comes like "FoundNetworkBug" or "FoundNoBug"
expected output
{
"application" : "android",
"issue" : "FoundCriticalBug",
"bug" : "critical"
}
There would be a if-else
condition applied but i didn't went further. do suggest.
CodePudding user response:
You can use a hash symbol(#
) for the case only when the issue
is equal to
FoundCriticalBug
(considering the three presented fixed values) in order to generate a line
"bug" : "critical"
representing a new attribute as follows
[
{
"operation": "shift",
"spec": {
"*": "&",
"issue": {
"FoundCriticalBug": {
"@1": "&2",
"#critical": "bug"
},
"*": {
"@1": "&2"
}
}
}
}
]