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?

7

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>
| improve this answer | |
  • oh wow, that was simple - thanks!! – zuzannamj Aug 12 '19 at 13:14

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.