我可以帮助您翻译。这篇文章涉及编程相关内容。需要将一个非常大的json schema转换成Angular Tree Control支持的treemodel格式,但是该json schema不完全符合Angular Tree Control支持的treemodel格式。例如,模式中的子级(属性)不在数组中。如何将json schema转换为treemodel格式?
该模式看起来像这样(除了更复杂,具有多达10个嵌套级别):
为了在 Angular 树控件中正确渲染,它需要像这样:
该模式看起来像这样(除了更复杂,具有多达10个嵌套级别):
{
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"address": {
"type": "object",
"properties": {
"addressLine1": {
"type": "string"
},
"addressLine2": {
"type": "string"
}
}
}
}
}
为了在 Angular 树控件中正确渲染,它需要像这样:
{
"type": "object",
"properties": [
{
"name": "firstName",
"type": "string"
},
{
"name": "lastName",
"type": "string"
},
{
"name": "address",
"type": "object",
"properties": [
{
"name": "addressLine1",
"type": "string"
},
{
"name": "addressLine2",
"type": "string"
}
]
}
]
}