Search code examples
jsonsalesforceexacttargetampscript

ExactTarget - JSON Feed as source


Having a tough time with ExactTarget's documentation. The example below from their docs works just fine, but I'm having trouble setting the var Json to an actual JSON feed. What am I missing?

 %%[ var @Json set @Json = ' [{"emailaddress":"[email protected]","Region":"West","State":"California","City":"San Francisco"},
 {"emailaddress":"[email protected]","Region":"Central","State":"Indiana","City":"Indianapolis"}]' ]%%

 {{.datasource JSONVar type=variable maxRows = 20}}
    {{.data}}
    { "target" : "@Json" }
    {{/data}}
    Email Address: {{emailaddress}}
    Region: {{region}}
    State: {{STATE}}
    City: {{JSONVar.City}}
 {{/datasource}}

Solution

  • Have you looked into using Server-Side Javascript? Ampscript does not contain a function for parsing JSON. However, SSJS does.

    Also for future reference, consider posting you questions at salesforce.stackexchange.com under the tag Marketing-Cloud.

    reference: