Convert String into Object in Advanced PDF Template

In FreeMarker, you can use the ?eval directive to evaluate a string as a FreeMarker expression. Here’s how you can convert a string representing a JSON object into an actual object in an Advanced PDF/HTML template:

<#assign jsonString = ‘{“line”:”1″,”remaining”:1}’>

<#assign jsonObject = jsonString?eval?json_string>

<tr>

  <td>Line: ${jsonObject.line}</td>

  <td>Remaining: ${jsonObject.remaining}</td>

</tr>

Leave a comment

Your email address will not be published. Required fields are marked *