I am given the below json and it needs to be concatenated based on condition if it not null
{
"id": "4583",
"price": "149.99",
"sale_price": ""
}
Can someone help me out here?
expected output
{
"id": "4583",
"price": "149.99 EUR",
"sale_price": ""
}
In above json price was concatenated with EUR but sale_price is as it is because it is null.
I am using below jolt, it us updating sale_price as well.
{
"operation": "modify-overwrite-beta",
"spec": {
"price": "=concat(@(1,price),' EUR')",
"sale_price": ["=isNull", "=concat(@(1,sale_price),' EUR')"]
}
}
2
Answers
I hope the following Jolt solution will be helpful to you.
The empty value(
""
) and thenull
value are different. So, we need to manipulate an empty value in order to convert to anull
one, and consequently to be able to apply theisNull
and thenotNull
functions such asOperator