是否有可能有一个定制的正式模型?
例如,对于以下正式配置:
[
{
"key": "g1",
"type": "repeat",
"fieldArray": {
"fieldGroup": [
{
"key": "a",
"type": "repeat",
"fieldArray": {
"fieldGroup": [
{
"type": "textarea",
"key": "ta1"
}
]
}
}
]
}
},
{
"key": "ta2",
"type": "textarea"
}
]
相应的正式模型是这样的:
{
"g1": [
{
"a": [
{ "ta1": "value for a index 0, ta1 index 0" },
{ "ta1": "value for a index 0, ta1 index 1" },
{ "ta1": "value for a index 0, ta1 index 2" }
]
},
{
"a": [
{ "ta1": "value for a index 1, ta1 index 0" },
{ "ta1": "value for a index 1, ta1 index 1" },
{ "ta1": "value for a index 1, ta1 index 2" }
]
}
],
"ta2": "value for ta2"
}
我想有与每个节点关联的自定义 ID,尤其是对于数组节点。我需要将数组中的字段与外部模型相关联,并且由于正式不保留数组项的 ID,因此在许多情况下很难找到哪些数组项已被删除/修改。
我想将正式模型存储为这样的东西
{
"g1": {
"children": [
{
"id": "a1",
"key": "a",
"children": [
{ "id": "a1.v1", "ta1": "value for ta1 index 0" },
{ "id": "a1.v2", "ta1": "value for ta1 index 1" },
{ "id": "a1.v3", "ta1": "value for ta1 index 2" }
]
},
{
"id": "a2",
"key": "a",
"children": [
{ "id": "a2.v1", "ta1": "value for ta1 index 0" },
{ "id": "a2.v2", "ta1": "value for ta1 index 1" },
{ "id": "a2.v3", "ta1": "value for ta1 index 2" }
]
}
]
},
"ta2": "value for ta2"
}
请让我知道这是否可能。谢谢!