我想用递归 JSON 做一个车把模板,但我不知道 JSON 的键是什么(可能会改变),我还需要一个 IF 语句,它正在工作。有什么方法可以创建一个 Helper 来做到这一点?现在我的答案是[object object]。这是我的 jsfiddle https://jsfiddle.net/deherinu/dvn4076h/
我的 JSON:
var json={
"results": [
{
"collection": "employer",
"summary":{
"person": [
{ "name": "My name" },
{ "lastname": "My lastname" },
{ "address": "Street" }
],
"job": "CEO"
}
},
{
"collection": "employer",
"summary":{
"person": [
{ "name": "My name" },
{ "lastname": "My lastname" },
{ "address": "Street" }
],
"job": "Administrator"
}
},
{
"collection": "company",
"summary": "Company1"
},
{
"collection": "company",
"summary": "Company2"
}
]
};
谢谢!