1

I'm having issues with space characters in JSON object names. GTL does not find the names in a JSON object if the name contains spaces.

I have a "Shipping Address" JSON object that looks like this (which is in a content Data Extension field):

"Shipping Address":{ 
      "Shipping First Name":"Simon",
      "Shipping Last Name":"Basic",
      "Shipping Address 1":"12/12 Sunshine Road",
      "Shipping Address 2":"",
      "Shipping SuburbCity":"Sampletown",
      "Shipping State":"VIC",
      "Shipping Postcode":"1234",
      "Shipping Country":"Australia"
   }

Here's the code in my email:

%%[
VAR @content
SET @content = content
]%%
{{.datasource order type=variable source=@content}}
  {{.data}}
    {"target":"@content"}
  {{/data}}

  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
    {{.datasource address type=nested}}
        {{.data}}
          {"target":"order.Shipping Address"}
        {{/data}}
      <td class="txt-16" style="font-family: Georgia, Arial, sans-serif; font-size: 12px; line-height: 20px; color: #777777;">{{Shipping First Name}} {{Shipping Last Name}}
      <br>{{Shipping Address 1}} {{Shipping Address 2}} {{Shipping SuburbCity}}<br>
      {{Shipping State}} {{Shipping Country}} {{Shipping Postcode}}</td>
    {{/datasource}}
    </tr>
  </table>

When I preview the email, the mustache tags are not replaced with the data, they are just empty.

However, if I replace the spaces with another character, for example, "Shipping_Address", "Shipping_First_Name", etc then it works fine.

Space characters should be allowed, as this is valid JSON. Does anyone know a solution to this?

1
  • I note that the documentation states Use quotes around variables or other text that include any reserved characters or spaces. Use brackets to quote tag names. We've tried using "quotes" and [brackets] but these do not appear to work. Jun 23, 2016 at 1:08

1 Answer 1

2

Tag names containing space characters need to be escaped in brackets. For example: {{[Order Sub Total]}}. I thought I tried this previously, but this is working now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .