I really need a hand here. In the last 2 or 3 hours I tried to simply list a JSON object in freemarker with a javascript backed webscript and no luck.
let's name my script as x, so:
x.get.js
function main(){
//model.data = {'name':'Test Object','size':100};
model.data={
"2012": {
"A": {
"a": "on",
"b": "off",
"list": [
1,
2,
3,
4
]
}
},
"2013": {
"B": {
"c": "on",
"d": "off"
}
}
};
logger.log(jsonUtils.toJSONString(model.data));
}
main();
x.get.html.ftl
<#assign keys = data?keys>
<#list keys as tag>
${jsonUtils.encodeJSONString(tag)}<#if tag_has_next>,</#if>
</#list>
When I try just with the first model.data (commented out) it works fine, and the logger writes out the full JSON, i get the "name, size" in the rendered HTML.
However, when I try like this, I get nothing in the rendered HTML, and logger says weird things:
{"2012":"org.mozilla.javascript.UniqueTag@1a31e0a: NOT_FOUND","2013":"org.mozilla.javascript.UniqueTag@1a31e0a: NOT_FOUND"}
So what? This JSON is valid too, so I miss some conversation or misterious function or what?
Thanks for the help
J.