SHARE
TWEET

Untitled

a guest Oct 17th, 2017 362 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %%[ set @JSON = HttpGET("http://some-url-that-returns-json") ]%%
  2.  
  3. <script runat="server">
  4.     Platform.Load("Core", "1")
  5.     // get JSON from ampscript
  6.     var jsonObj = Variable.GetValue("@JSON");
  7.     var evaluatedJSON = eval("(" + jsonObj + ")");
  8. </script>
  9.    
  10. %%[
  11.  
  12. var @Json
  13. set @Json = '[{"name": "john doe","email": "john.doe@mail.com"},{"name": "jane doe","email": "jane.doe@mail.com"}]'
  14.  
  15. ]%%
  16. {{.dataobject JsonVar type=variable source=@Json maxrows=20}}
  17.      {{.data}}
  18.           {"target":"@Json"}
  19.      {{/data}}
  20. {{/dataobject}}
  21. {{#each JsonVar}}
  22.   <br><br>Name: {{name}}
  23.   <br>Email: {{email}}
  24. {{/each}}
  25.    
  26. Name: john doe
  27. Email: john.doe@mail.com
  28.  
  29. Name: jane doe
  30. Email: jane.doe@mail.com
  31.    
  32. "[{"name":"john doe","email":"john.doe@mail.com"},{"name":"jane doe","email":"jane.doe@mail.com"}]"
  33.    
  34. %%[
  35.    var @json
  36.    set @json = AttributeValue("Recipient_List")
  37. ]%%
  38.  
  39. {{.dataobject JsonVar type=variable source=@json maxrows=20}}
  40.    {{.data}}
  41.         {"target":"@Json"}
  42.    {{/data}}
  43. {{/dataobject}}
  44. {{#each JsonVar}}
  45.    <p>{{name}}, {{email}}</p>
  46. {{/each}}
  47.    
  48. <script runat="server">
  49.      var str = '{ "prop1": "propVal" }';
  50.      var obj = Platform.Function.ParseJSON(str);
  51.      var val = obj.prop1;
  52. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top