Skip to main content

output application/json

var test = map (payload.body scan ('\{[a-z, A-Z]*\}'), ((value, valueIndex) -> value[0] replace "{" with ("") replace "}" with ("")))

---

map (test, ((value, valueIndex) -> "'{" ++ value ++ "}': " ++ vars.notificationData.value))

 

Basically ['{username}': Mike@this.com, '{firstName}': Mike]

 

-----

 

var test = map (payload.body scan ('\{[a-z, A-Z]*\}'), ((value, valueIndex) -> value[0] replace "{" with ("") replace "}" with ("")))

 

spits out

 

[

 "firstName",

 "username",

 "etc"

]

 

map (test, ((value, valueIndex) -> "'{" ++ value ++ "}': " ++ vars.notificationData.value))

 

fails

 

map (test, ((value, valueIndex) -> "'{" ++ value ++ "}': " ++ vars.notificationData."$(firstName)"))

or

map (test, ((value, valueIndex) -> "'{" ++ value ++ "}': " ++ vars.notificationData.firstName))

 

works and outputs

 

[

 "'{firstName}': Mike"

]

 

Basically I want (in the above situation)

 

the value == firstName when the code is evaluating vars.notificationData.xyz

1 Antwort
  1. 31. Jan. 2023, 22:36

    Use [] bracket, this would help you

     

    map (test, ((value, valueIndex) -> "'{" ++ value ++ "}': " ++ vars.notificationData[value]))

    Else share the proper input and output with code