I need to check the existence of a particular keyword in a JSON object and based on that, create a string. My sample dataweave 2.0 code is given below:
%dw 2.0
output application/json
var arr = {
"ID": "100",
"ProdId": "Prod",
"ProdName": "ABC"
}
---
if (arr pluck $$ joinBy ';' contains "ProdId") == true
then (String: "Product") else
if (arr pluck $$ joinBy ';' contains "EmpId") == true
then (String: "Employee") else null
Based on the value of the variable, I need to have different String values. What change is needed above to work?