How to fetch record from .imp file in mule 4

64 Views Asked by At

I have a payload which is coming from a .imp file, the records inside the payload [ORDRUPDT|U|O-40541|C| ORDRUPDT|U|O-40536|C| ORDRUPDT|U|O-40537|C| ORDRUPDT|U|O-40538|C| ORDRUPDT|U|O-40539|C| ORDRUPDT|U|O-40540|C|] I need to fetch value of column 1, 4 and 3, in mule 3 we can fetch using $[0], $[2] etc. but in mule 4 $[0] syntax doesn't support. can you please help me to fetch the record.

1

There are 1 best solutions below

0
On

Code:

%dw 2.0
import * from dw::core::Arrays
output application/json
---
payload
    replace "[" with("")
    replace "]" with("")
    replace(" ") with ("")
    splitBy("|")
    divideBy 4
    map() -> $[0] ++ "|" ++ $[3] ++ "|" ++ $[2]

Result:

[
  "ORDRUPDT|C|O-40541",
  "ORDRUPDT|C|O-40536",
  "ORDRUPDT|C|O-40537",
  "ORDRUPDT|C|O-40538",
  "ORDRUPDT|C|O-40539",
  "ORDRUPDT|C|O-40540"
]