Skip to content

Instantly share code, notes, and snippets.

@jacksonpchen
Last active December 2, 2020 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacksonpchen/4c427d5d1450d7059f93a05b7fadfb61 to your computer and use it in GitHub Desktop.
Save jacksonpchen/4c427d5d1450d7059f93a05b7fadfb61 to your computer and use it in GitHub Desktop.
/*
AMPscript.com
https://ampscript.com/parsing-json-with-ampscript/
*/
%%[ set @JSON = '{"name": AMPscript.com","email": "AMPscript@ampscript.com"}' ]%%
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title ></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script runat="server">
Platform.Load("Core", "1")
var str = Variable.GetValue("@JSON");
var obj = Platform.Function.ParseJSON(str);
var val = obj.name;
Variable.SetValue("@output",val);
</script>
Output: %%=v(@output)=%%
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment