I have a message saved down from azure service bus and would like to extract some details at a much larger number of messages but the dataweave code I wrote in playground works but when being plugged into a transform component it throws an error like the below.
I’ve tried multiple variations of it but Nothing seems to work. When the message is saved the structure is an array of json data that contains escaping characters and new line \n from my understanding read() should do the trick and its working in the playground.
Example of a partial payload not sure if I put the proper ending brackets when I cut it.
[
{
"body": "{\n \"tenant\": \"some_text\",\n \"name\": \"order.opened\",\n \"published_at\": \"2024-03-08T14:37:39.315Z\",\n \"payload\": {\n \"id\": \"d9b5361a-8921-4fc0-8ad5-8073ea457g97\",\n \"external_id\": \"000009996417\"}]
The error:
""You called the function 'Value Selector' with these arguments: 1: String ("{") 2: Name ("body") But it expects one of these combinations: (Array, Name) (Array, String) (Date, Name) (DateTime, Name) (LocalDateTime, Name) (LocalTime, Name) (Object, Name) (Object, String) (Period, Name) (Time, Name) 4| read(payload[0].body, "applicaiton/json") ^^^^^^^^^^^^^^^ Trace: at anonymous::main (line: 4, column: 6)" evaluating expression: "%dw 2.0 output application/json --- read(payload[0].body, "applicaiton/json")"."
Tried read() and was expecting to parse the string to a properly formatted json payload but got an error when I try on a transform component.