3

I am unable to extract msg from the JSON response. @returnCode works fine and I am passing it to SSJS, but then I cannot get the msg value.

<script runat="server" language="javascript">
Platform.Load("Core","1");
var jsonresponse = Variable.GetValue("@response");
var json = Platform.Function.ParseJSON(jsonresponse.msg);
Write("<br>message: " + msg);
</script>

Here's my json for reference:

{"msg":"success","date":"2019-08-12","explanation":"xxxxxxx"}

Any idea what is wrong with above?

1 Answer 1

8

You don't have any variable named msg. Try this:

<script runat="server" language="javascript">
Platform.Load("Core","1");
var jsonresponse = Variable.GetValue("@response");
var json = Platform.Function.ParseJSON(jsonresponse);
Write("<br>message: " + json.msg);
</script>
1
  • oh wow, that was simple - thanks!!
    – zuzannamj
    Aug 12, 2019 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .