I have requirement where I need to put together a set of string and a object. Which am trying different ways but unable to do so please help me. example- abc xyz back space { "hello":"world" }
An object and a string can not be concatenated together since they are of incompatible types. However you can "print" the object to a string, and then concatenate it.
Example:
%dw 2.0
output application/java
var payload1={ "employee": "sara", "categories": { "id": "employee01", "name": "sara" } }
var payload2="QU sara world BACF MESSAGE"
---
write(payload1,"application/java") ++ " " ++ payload2
Output (of type string): {employee=sara, categories={id=employee01, name=sara}} QU sara world BACF MESSAGE