<分区>
我想要实现的是,从像这样(示例)的 JSON 对象(多级)开始:
[
{
"geometry": {
"location": {
"lat": 37.3860517,
"lng": -122.0838511
},
"viewport": {
"northeast": {
"lat": 37.4508789,
"lng": -122.0446721
},
"southwest": {
"lat": 37.3567599,
"lng": -122.1178619
}
}
},
"name": "Mountain View",
"scope": "GOOGLE",
"data": {
"customKey1": "customValue1",
"customKey2": {
"customSubKey1": {
"customSubSubKey1": "keyvalue"
}
},
},
"types": [
"locality",
"political"
]
}
]
在不知道属性名称或级别的情况下(因为并非对象的所有元素都具有相同的属性)创建一个基本的嵌套 HTML 列表,如 this (键是粗体,值是正常的)。
我在 SO 上尝试了一些解决方案来从 JSON 创建列表,但这些解决方案需要属性的名称或知道对象的级别,在我的例子中,这个对象将动态生成。
是否可以从未知的 JSON 对象创建 HTML 列表?