Last active
December 2, 2020 05:11
-
-
Save jacksonpchen/4c427d5d1450d7059f93a05b7fadfb61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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