データオブジェクトタグの例
データオブジェクトの AMPscript の例
次の例では、セクションタグで参照される 1 つのデータオブジェクトタグを使用して、AMPscript 変数から情報を読み込みます。
1%%[ var @Json set @Json = ' {"emailaddress":"sam@example.com <mailto:sam@example.com>","Region":"East","State":"North Carolina","City":"Charlotte"}' ]%%
2{{.dataobject JsonVar type=variable source=@Json maxrows=20}}
3 {{.data}}
4 {"target":"@Json"}
5 {{/data}}
6{{/dataobject}}
7{{#jsonvar}}
8Email Address: {{emailaddress}}
9Region: {{region}}
10State: {{state}}
11 City: {{JSONVar.City}}
12{{/jsonvar}}この例では、次の情報が生成されます。
1Email Address: sam@example.com <mailto:sam@example.com>
2Region: East
3State: North Carolina
4City: CharlotteJSON データのフィルターおよび並び替えの例
次の例では、データオブジェクトタグを使用してデータエクステンションから JSON データを読み込み、そのデータのフィルターおよび並び替えを行います。
1{{.dataobject JsonVar type=variable maxrows=20}}
2 {{.data}}
3 {
4 "target":"key:JsonData.JsonData",
5 "filter" : "EmailAddress == EmailAddr",
6 "order" : [ "EmailAddress ASC", "[_CustomObjectKey] DESC" ]
7 }
8 {{/data}}
9{{/dataobject}}
10{{#jsonvar}}
11 Email Address: {{emailaddress}}
12 Region: {{region}}
13 State: {{STATE}}
14 City: {{JSONVar.City}}
15{{/jsonvar}}この例では、次の情報が生成されます。
1Email Address: john@example.com
2Region: West
3State: California
4City: San Francisco1Email Address: carla@example.com
2Region: Central
3State: Indiana
4City: Indianapolis1Email Address: sam@example.com
2Region: East
3State: North Carolina
4City: Charlotte