1

I have this below json from this below code

"SMTPMessage":"%%=v(Field(@row,"SMTPMessage"))=%%"

"SMTPMessage":"{"Source":"MITS_LOG", "Machine":"ATL1S07WSLOT042"}"

Now i want to make it as a single string like below

"SMTPMessage":"Source:MITS_LOG-Machine-ATL1S07WSLOT042"

How can we do it in ampscript.

Regards

0

I would use Guide Template Language to parse your JSON object in conjunction with AMPscript. So your code would look like this:

%%[
var @SMTPMessage
set @SMTPMessage = Field(@row,"SMTPMessage")
]%%

  {{.datasource SMTPMessage type=variable}}
  {{.data}}
  { "target" : "@SMTPMessage" }
  {{/data}}

<p>"SMTPMessage":"Source:{{Source}}-Machine-{{Machine}}"</p>

  {{/datasource}}

Note that if you are using this on a CloudPage, you need to reset delimiters in OMM by adding this line after your AMPscript block:

%%{={{ }}=}%%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.