Skip to main content

My input is :

[ {

"Booking Loca" : [ "Seedict Sparango","Cando Wall Communities","Maul O'donor","Ahohn kappler" ]

} ]

 

in this input there is a chance to get Name coming like Maul O'donor but I need to replace one single quote to Maul O''donor

 

The final Output Required Like below :

[Booking Loca] in ('Seedict Sparango','Cando Wall Communities','Maul O''donor','Ahohn kappler')

 

for this I am using below Data weave logic but at beginning and ending not getting single quote instead

%dw 2.0

output application/java

import * from dw::core::Strings

---

"[Booking Loca] in ("++((flatten(payload."Booking Loca")) map (wrapWith($,"'")) joinBy ",") replace "'" with '"' replace '","' with "','"++ ")"

 

Here I have a struggle with a small transformation hence please help me

1 answer
  1. Jul 2, 6:19 AM

    Hello, 

     

    Please try the below dataweave.  

     

    %dw 2.0

    output application/java

    ---

    "[Booking Loca] in (" ++

    ((payload[0]."Booking Loca" map ("'" ++ ($ replace "'" with "''") ++ "'")) joinBy ",")

    ++ ")" 

     

    Thanks!

0/9000