%dw 1.0
%output application/json
---
"cafm" splitBy "" map ($ ++ "_" when $$ == 0 otherwise $) reduce ($$ ++ $)
%dw 2.0
output application/json
---
"cfam" splitBy "" map (if ($$ == 0) $ ++ "_" else $) reduce ($$ ++ $)
%dw 1.0
%output application/json
---
"cafm" splitBy "" map ($ ++ "_" when $$ == 0 otherwise $) reduce ($$ ++ $)
%dw 2.0
output application/json
---
"cfam" splitBy "" map (if ($$ == 0) $ ++ "_" else $) reduce ($$ ++ $)
The following is a helpful Dataweave (2.0) code to allow you to extract cookie value coming in via Cookie
header.
%dw 2.0
output application/java
---
(payload splitBy "; " map ($ splitBy "=") reduce (item, accum = {}) -> (accum ++ { (item[0]): item[1] })) ['csrftoken']
"PHPSESSID=413; csrftoken=444t4#tb3gg43; _gat=1"
444t4#tb3gg43