【发布时间】:2017-03-24 08:05:29
【问题描述】:
我得到了以下转换模板:
var transform = {'<>':'li','html':'${name} - ${version} - ${licenseSources.package.sources[0].license}'};
现在我想用 json2html 将 JSON 转换成 HTML:
var html = json2html.transform(data,transform);
JSON 看起来像这样:
{
"id": "xxx",
"name": "xxx",
"version": "0.0.14-SNAPSHOT",
"repository": "xxx",
"directory": "./",
"type": "(none)",
"licenseSources": {
"package": {
"sources": [{
"license": "BSD",
"url": "(none)"
}
]
},
"license": {
"sources": [{
"filePath": "xxx",
"text": "xxx"
}, {
"filePath": "xxx",
"text": "xxx"
}
]
},
"readme": {
"sources": [{
"filePath": "xxx",
"text": "xxx"
}
]
}
}
}
我想通过转换变量访问 licenseSouce.package.sources.license = "bsd"。但我无法弄清楚符号。
有人可以帮忙吗?
提前谢谢
【问题讨论】:
标签: javascript html json node.js json2html