I have stored a json-string in a lead field in marketo =>
{
"name": "Milan",
"cm_name": "Master Manager",
"signature": "Hello \"There\"",
}
When I am trying to parse the json string using the following script =>
#if( $lead.emailVariables.isEmpty() )
#set( $lead.emailVariables = '{}' )
#end
#set( $emailVariables = '#set( $emailVariables = ' + $lead.emailVariables + ' )' )
#evaluate( $emailVariables )
I am getting this error ->
Cannot get email content- <div>An error occurred when procesing the email Body! </div> <p>Encountered "There" near</p> <div><pre >#end</pre><pre >#set( $emailVariables = '#set( $emailVariables = ' + $lead.emailVariables + ' )' )</pre><pre class="x-form-item-label">#evaluate( $emailVariables ) </span> </pre><pre ><div></pre><pre >Dear ${lead.vFIRST_NAME_1}</pre></div>
Solved! Go to Solution.
Velocity only supports long-form JSON Unicode escapes. It doesn’t support shortcuts like \"
or \n
. For the double quotes you use \u0022
.
Got it. Thanks for the help.
hi
I have followed the same steps, but still no luck in parsing the JSON from my Custom Object.
My Custom Object field (Field Name: RData) has data like below
[
{
"StuLast": "Abram",
"StuFirst": "Easton",
"Program": "UGD",
"Subject": "MUSC",
"Catalog": "10A",
"Section": 90
},
{
"StuLast": "StuLast2",
"StuFirst": "StuFirst2",
"Program": "UGD",
"Subject": "Chemistry",
"Catalog": "20B",
"Section": 65
}
]
When I tried the following code in the Token to parse, I am getting an empty string
#set($data = ${registrar_cList.get(0).rData})
#if($data.isEmpty())
#set($data='{}')
#end
#set($parsedJson = '#set($parsedJson='+ $data+')')
#evaluate($parsedJson)
$parsedJson['subject']
My Custom object has data like
[
{
"StuLast": "Abram",
"StuFirst": "Easton",
"Program": "UGD",
"Subject": "MUSC",
"Catalog": "10A",
"Section": 90
},
{
"StuLast": "StuLast2",
"StuFirst": "StuFirst2",
"Program": "UGD",
"Subject": "Chemistry",
"Catalog": "20B",
"Section": 65
}
]
When I tried the following code in the Token to parse, I am getting an empty string
#set($data = ${registrar_cList.get(0).rData})
#if($data.isEmpty())
#set($data='{}')
#end
#set($parsedJson = '#set($parsedJson='+ $data+')')
#evaluate($parsedJson)
$parsedJson['subject']
Note: I did upload the csv file into Marketo as UTF-8 format when updating the Custom object.
My Goal is to display data from this Custom object field in an email.
Any help is appreciated.
thanks
-Sree
Responded in the other thread. Please don’t cross-post, thanks.