Reputation: 1
OptIn: "Yes" when payload.country==true and payload.state==false otherwise "No" when payload.country==false and payload.state==true otherwise "NOT VALID" when payload.country==false and payload.state==false otherwise ""
Upvotes: 0
Views: 11588
Reputation: 8311
This can be achieve through following example :-
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="DataweaveFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/poc" doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[ %dw 1.0
%input payload application/json
%output application/json
---
{ value1: "Yes" } when payload.country==true and payload.state==false
otherwise (
{ value1: "No" } when payload.country==false and payload.state==true
otherwise (
{ value1: "NOT VALID" } when payload.country==false and payload.state==false
otherwise "your value"
))]]></dw:set-payload>
</dw:transform-message>
<logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger" />
</flow>
Where I tested this with following input :-
case 1:-
{
"country":true,
"state":false
}
case 2:-
{
"country":false,
"state":true
}
case 3:-
{
"country":false,
"state":false
}
case 4:-
{
"country":true,
"state":"default value"
}
Upvotes: 2