I am trying to send out personalized emails using GTL and AmpScript but i was wondering if you can pass custom data in the form of a JSON object within a data extension For example if a Data extension has the following fields:-

"id": 100
"name" : "qwerty"
"custom_data" : {"custom_text" : "abc", "another_key" : "another_value"} 

Note that this "custom_data" field can have any other key : value pairs as well So another record of data could have

"custom_data" : {"test" : "abcd", "some_key" : "another_value"} 
  • Whats your use case? – gNerb Aug 21 '18 at 20:45
  • 1
    Yes, but what you've provided isn't valid JSON. Plus this topic is has been discussed a lot around here – Adam Spriggs Aug 21 '18 at 21:21
  • Sorry, i didn't clarify my use case. My problem is more related to the "custom_data" key which has a text value passed as a JSON string. This field can hold any random json string. The problem here is that since the JSON string is dynamic and I wouldn't know what it is until it gets passed by a user, I will not be able to create a generalized template for all users. So if one record holds a JSON string of 3 attributes, another record may have 5 attributes that are all different – vishesh hemnani Aug 22 '18 at 14:32

Assuming your Sendable DE has a field named 'custom_data' which contains the following value for a Subscriber:

{"test" : "abcd", "some_key" : "another_value"}

Then you could use the following code to display these values in your email:

var @customData
set @customData = AttributeValue('custom_data')

{{.datasource order type=variable source=@customData}}

The value of 'test' is: {{test}}

The value of 'some_key' is: {{some_key}}


This code will produce the output:

The value of 'test' is: abcd

The value of 'some_key' is: another_value

Note that GTL also supports arrays and nested objects too.

Not the answer you're looking for? Browse other questions tagged or ask your own question.