We are currently passing a string attribute via the REST API that contains JSON.
{ "User_List": "[{\"name\":\"john doe\", \"email\":\"[email protected]\"}, {\"name\":\"jane doe\", \"email\":\"[email protected]\"}]" }
We then use server side JavaScript to parse the attribute string value into JSON.
<script runat=server>
Platform.Load("Core","1");
var userList = Platform.Recipient.GetAttributeValue("User_List");
var userListObj = Platform.Function.ParseJSON(userList);
</script>
We then later use that JSON to build a dynamic list from the JSON data.
<p>
<script runat=server>
Write("<ul>");
for (var i = 0; i < userListObj.length; i++) {
Write("<li>" + userListObj[i].name + ", " + userListObj[i].email + "</li>");
}
Write("</ul>");
</script>
</p>
My question is, is there a way to do this via AMPscript? I couldn't find anything about parsing a string into JSON via AMPscript.