We Use Cookies

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with this.

See our cookie policy.

Automation Action: Convert JSON To HTML

Convert Json to a readable HTML table and assign the HTML to a variable.

Built-In Action

Converts any Json text to a HTML table.

This action is useful when you read Json data from a database, web resource or web API etc., and you need to easily convert the content to readable HTML. The HTML can then be included on outgoing emails or used as a return value for webform Message Sources.

In the Json editor, enter or paste the Json text, or use a %variable% replacement for Json created from an earlier action.

The Preview window will show a preview of the HTML created. The Json will be converted to a HTML table. Sub-objects/arrays etc will be converted into nested tables.

You can optionally add a Title which will appear above the table.

Enable the Convert Property Names option to convert camelCase property names into separate words. For example: customerName will appear as Customer Name.

If the Return Full Page option is enabled then the returned HTML will include html, body, head tags. Otherwise only the table html will be returned. This is useful if you are embedding the table into an existing HTML document.

If the Use Default Styles option is enabled then the table will have a default style sheet applied.

You can also optionally add any custom CSS (eg: body {background-color: lightblue;}).

Select the ThinkAutomation variable to receive the HTML from the Assign Html To list.

Example:

The following Json:


{
    "Name": "ABC Limited",
    "EmailAddress": "a.dutchess@abclimited.com",
    "Address": {
        "AddressType": "POBOX",
        "AddressLine1": "P O Box 123",
        "City": "Wellington",
        "PostalCode": "6011",
        "AttentionTo": "Andrea"
    },
    "Currency": "NZD"
}              

Would be converted to:


<table>
    <tbody>
      <tr>
        <td><b>Name</b></td>
        <td>
          ABC Limited
        </td>
      </tr>
      <tr>
        <td><b>Email Address</b></td>
        <td>
          <a href='mailto:a.dutchess@abclimited.com' target='_blank'>a.dutchess@abclimited.com</a>
        </td>
      </tr>
      <tr>
        <td><b>Address</b></td>
        <td>
          <table>
            <thead>
              <tr>
                <th>Address Type</th>
                <th>Address Line1</th>
                <th>City</th>
                <th>Postal Code</th>
                <th>Attention To</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>POBOX</td>
                <td>P O Box 123</td>
                <td>Wellington</td>
                <td>6011</td>
                <td>Andrea</td>
              </tr>
            </tbody>
          </table>
        </td>
      </tr>
      <tr>
        <td><b>Currency</b></td>
        <td>
          NZD
        </td>
      </tr>
    </tbody>
  </table>