Open ASHISHTOM opened 4 years ago
I developed a spec myself to add a new json element called "safe":"true" if the credit score value matches 200. I am attaching the spec below: -
[
{
"operation": "shift",
"spec": {
"billingsystem": {
"profile": {
"@": "billingsystem.&",
"credit_score": {
"200": {
"#true": "billingsystem.profile.safe"
}
}
}
}
}
}
]
Hi, @ASHISHTOM I use a function to splice two condition values into a key value, and then shift operation.
[
{
"operation": "modify-overwrite-beta",
"spec": {
"billingsystem": {
"profile": {
"key":"=join('_', @(1,risk_category) , , @(1,credit_score))"
}
}
}
},{
"operation": "shift",
"spec": {
"billingsystem": {
"profile": {
"profile_type": "billingsystem.profile.profile_type",
"risk_category": "billingsystem.profile.risk_category",
"credit_score": "billingsystem.profile.credit_score",
"key": {
"2_200": {
"#true": "billingsystem.profile.safe"
}
}
}
}
}
}
]
I think Jolt is very good at structural transformation, but the comparison of correlation conditions does not perform very well. Maybe it can be enhanced on functions. What do you think about this?
Suppose I have an input json with a few json elements like this.
I want to add a new json element called "safe":"true" , when my json elements "risk_category " is equal to 2 and "credit_score" is equal to 200. Otherwise don't add any new element.
My new output json will be like:
Is it possible with jolt transform?? And what is the suitable spec for this requirement??