Having the following DE as example:
I recommend using the attributes with single quotes
You could add this Script to your Email Message:
%%[
VAR @color, @skey
set @skey = _subscriberkey
]%%
<script runat=server>
Platform.Load('Core', '1.1.5');
var skey = Variable.GetValue("@skey");
var DEName = 'TEST JSON';
var records = Platform.Function.Lookup(DEName,'JSON','Email', skey);
var parsedResult = Platform.Function.ParseJSON( records );
Variable.SetValue("@color", Stringify(records) );
</script>
color = %%=v(@color)=%%
this example Script gets the SubscriberKey and pass it to the SSJS (using the Variable.GetValue
) so the SSJS takes care of retrieving and parsing the field to JSON.
This script filter the row (in this case, for simplicity the field Email
correspond to the SubscriberKey used in the send context.
After retrieving and parsing (using Platform.Function.ParseJSON
) the field JSON
, SSJS changes the value of the AMP variable (Variable.SetValue
)
You can change the DEName
to your desired Data Extension, and use a different logic to rerieve the field.