我正在使用自定义 Tcl 脚本,它从文件中读取 JSON 并将其返回到 JavaScript 脚本中。我已经为这个 JSON 编写了一个简单的转换,但是当我执行它时,我得到了一个错误。有趣的是,当我内联粘贴相同的 JSON 时,它可以工作。我知道 Tcl 脚本一定有问题,但我似乎无法弄清楚它是什么。有什么建议么?
var datJSON = Tcl_Script_to_get_JSON;
//var datJSON = some_inline_JSON THIS WORKS!!
var trans = [
{ "tag" : "div", "id" : "reportTitle", "html" : "Report: ${Name}" }, //report title
{ //general Details, date, time, revision number
"tag" : "ul", "children" : [
{"tag" : "li", "class" : "generalDetails", "html" : "Created on : ${Date}"},
{"tag" : "li", "class" : "generalDetails", "html" : " at : ${Time}"},
{"tag" : "li", "class" : "generalDetails", "html" : "Revised for : ${RevisionNumber}"}
]
}
];
//run the JSON through the json2html transform
var output = json2html.transform(datJSON, trans);
$("#main").append(output);