0

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 ""

1 Answer 1

2

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"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.