This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import * from dw::util::Values | |
import * from dw::core::Strings | |
output application/json | |
fun lastNameMask(lastName) = lastName[0] ++ "***" | |
fun phoneMask(x) = "(###)-###-" ++ x[-4 to -1] | |
fun emailMask(email) = "***@" ++ substringAfterLast(email, "@") | |
type Currency = String{format: "\$#,###.00"} | |
var payload = { | |
"employees": [{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
output application/json | |
var payload = [{ | |
"id": "111", | |
"name": "Ernie", | |
"address": "Hulo" | |
}, { | |
"id": "112", | |
"name": "John", | |
"address": "Huawei", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
output application/json | |
import * from dw::core::Strings | |
var payload = { | |
"data": { | |
"schema": "g5uhJxM3EDHB9UQ5rdqfhw", | |
"payload": { | |
"BillingAddress": { | |
"State": "MN", | |
"Street": "45 WEST 132ND RD", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import * from dw::core::Strings | |
output application/json | |
var request = { | |
"message": "((drawingName1)){{v1}}||((drawingName2)){{v2}}||((drawingName3)){{v3}}|" | |
} | |
var p = request.message splitBy '||' | |
fun getStringBeforeAfter(str, after, before) = substringAfter(substringBefore(str,before), after) | |
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import divideBy from dw::core::Objects | |
output application/json | |
var payload = [ | |
{ "id":"1", "q1":"ans1", "q2":"ans2" }, | |
{ "id":"1", "q1":"ans11", "q2":"ans22", "q3":"ans33", "q4": "ans44" } | |
] | |
var resp = [ | |
{ "id":"1", "questionNum":"q1", "answer":"ans1" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import * from dw::core::Arrays | |
input payload application/csv header=false | |
output application/json | |
var GroupRecordHeaders = payload filter ($.column_0 == "03") | |
var GroupRecordHeaderIndices = GroupRecordHeaders map (indexOf(payload, $)) | |
var GroupRecordTrailers = payload filter ($.column_0 == "49") | |
var GroupRecordTrailersIndices = GroupRecordTrailers map (indexOf(payload, $)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
output application/json | |
var payload = [{ | |
a: " multi " | |
}, | |
{ | |
a: " rty " | |
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import java!org::apache::commons::lang3::StringUtils | |
output application/json | |
fun getNum(x)= (x replace /[- +()]/ with("")) | |
var payload = "+19876543210" | |
--- | |
{ | |
value: StringUtils::substring(getNum(payload), 1, sizeOf(getNum(payload))) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
output application/xml | |
var attributes = { | |
"queryParams": { | |
"countryID": "AV", | |
"regionID": "AV" | |
} | |
} | |
ns ws http://wwww.informatica.com/loc/ws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import * from dw::core::Strings | |
output application/json | |
var payload = [{ | |
"id": 1, | |
"name": "Book", | |
"quantity": 100 | |
}, | |
{ | |
"id": 2, |