Search code examples
mulemule-studioanypoint-studiodataweave

how to get array of integers in dataweave


I have input values as { {Id:"1"}, {Id:"2"}, {Id:"3"} }

I want output as array {1,2,3} in integer formats using DataWeave in mule anypoint studio so that I can use payload for querying records from sql server database instead looping using for each processor .

I want to use it as

select * from tblQuotes where id in #[payload]

update: It is required like

       select * from tblQuotes where id in (1,2,3)

Solution

  • Try following

    %dw 1.0
    %output application/json
    ---
    (payload map {
        id : $.Id as :number
    }).*id
    

    For input as

    [{"Id":"1"}, {"Id":"2"}, {"Id":"3"}]

    Output

    [1,2,3]

    Hope this helps