Created
May 19, 2023 07:50
-
-
Save avin/8189d0db58fc81d9242b82eb5fefc7db to your computer and use it in GitHub Desktop.
Freemarker dump all data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#-- JSON stringify --> | |
<#function stringify obj> | |
<#if !obj??> | |
<#return 'undefined'> | |
</#if> | |
<#if obj?is_date> | |
<#return '"' + obj?string("yyyy-MM-dd HH:mm:ss") + '"'> | |
</#if> | |
<#if obj?is_boolean || obj?is_number> | |
<#return obj?string> | |
</#if> | |
<#if obj?is_enumerable> | |
<#local str = '['> | |
<#list obj as x> | |
<#local str = str + stringify(x)> | |
<#if x_has_next> | |
<#local str = str + ',<br>'> | |
</#if> | |
</#list> | |
<#return str + ']'> | |
</#if> | |
<#if obj?is_string> | |
<#return '"' + obj?js_string + '"'> | |
</#if> | |
<#if obj?is_hash || obj?is_hash_ex> | |
<#local str = '{'> | |
<#local arr = [] > | |
<#local keys = obj?keys> | |
<#list keys as x> | |
<#if x!='class' && obj[x]??> | |
<#local arr = arr + [x]> | |
</#if> | |
</#list> | |
<#list arr as x> | |
<#local str = str + '"' + x + '" :' + stringify(obj[x])> | |
<#if x_has_next> | |
<#local str = str + ',<br>'> | |
</#if> | |
</#list> | |
<#return str + '}'> | |
</#if> | |
<#return ''> | |
<#if obj?is_string> | |
<#return '"' + obj?js_string + '"'> | |
</#if> | |
</#function> | |
${stringify(.data_model)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment