Reputation: 6334
I am receiving a payload as such:
{
"street": "123 fake st",
"city": "San Francisco"
"state": "CA",
"zip": 94117
}
but in my dataweave, it looks like the editor thinks that zip is a function. how to I get it to not think that? here is my dataweave:
Address: {
Street: payload.address.street,
City: payload.address.city,
State: payload.address.state,
Zip: payload.address.zip
},
the error being listed is on the "Zip: payload.address.zip"
thanks for the help
Upvotes: 0
Views: 184
Reputation: 1277
As mentioned by Anirban, that configuration is working properly. Indeed when we open the DataWeave code in Studio, the zip field is recognized as a function. And Studio lists it as an error.
Therefore to avoid the ambiguity, I suggest to wrap it inside a single quote: Zip: payload.address.'zip'
. No error listed anymore.
Upvotes: 1
Reputation: 8311
I found the following example working :
<flow name="application1Flow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message">
<dw:input-payload doc:sample="json.json"/>
<dw:set-payload><![CDATA[%dw 1.0
%input payload application/json
%output application/json
---
Address:{
Street: payload.address.street,
City: payload.address.city,
State: payload.address.state,
Zip: payload.address.zip
}]]></dw:set-payload>
</dw:transform-message>
<logger message="Payload #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</flow>
And the input request I used is :-
{
"address": {
"street": "123 fake st",
"city": "San Francisco",
"state": "CA",
"zip": 94117
}
}
Upvotes: 0