1. Frage: Konvertieren Sie die Form json1 in die Form json2
2 Beschreibung: Es kann unendlich viele Ebenen in den Eigenschaften geben, der Typ bezieht sich auf den Typ, der Array-Typ enthält Elemente und das Array kann ein Objektarray oder andere Typen sein.
json1:
body: {
"name": "body",
"in": "root",
"required": false,
"description": "",
"type": "object", //数据类型
"format": "",
"properties": {
"bcc": {
"name": "bcc",
"in": "body",
"required": false,
"description": "暗送人列表",
"type": "array",
"format": "",
"properties": null,
"items": {
"name": "bcc.*",
"in": "body",
"required": false,
"description": "每个暗送人",
"type": "object",
"format": "",
"properties": {
"address": {
"name": "bcc.*.address",
"in": "body",
"required": false,
"description": "单个暗送人地址",
"type": "string",
"format": "email",
"properties": null,
"items": null
},
"name": {
"name": "bcc.*.name",
"in": "body",
"required": false,
"description": "单个暗送人名称",
"type": "string",
"format": "",
"properties": null,
"items": null
}
},
"items": null
}
},
"cc": {
"name": "cc",
"in": "body",
"required": false,
"description": "抄送人列表",
"type": "array",
"format": "",
"properties": null,
"items": {
"name": "cc.*",
"in": "body",
"required": false,
"description": "每个抄送人",
"type": "object",
"format": "",
"properties": {
"address": {
"name": "cc.*.address",
"in": "body",
"required": false,
"description": "单个抄送人地址",
"type": "string",
"format": "email",
"properties": null,
"items": null
},
"name": {
"name": "cc.*.name",
"in": "body",
"required": false,
"description": "单个抄送人名称",
"type": "string",
"format": "",
"properties": null,
"items": null
}
},
"items": null
}
},
"content": {
"name": "content",
"in": "body",
"required": true,
"description": "邮件内容",
"type": "string",
"format": "",
"properties": null,
"items": null
},
"from": {
"name": "from",
"in": "body",
"required": true,
"description": "发件人",
"type": "object",
"format": "",
"properties": {
"address": {
"name": "from.address",
"in": "body",
"required": true,
"description": "发件人地址",
"type": "string",
"format": "email",
"properties": null,
"items": null
},
"name": {
"name": "from.name",
"in": "body",
"required": true,
"description": "发件人名称",
"type": "string",
"format": "",
"properties": null,
"items": null
}
},
"items": null
},
"mimeType": {
"name": "mimeType",
"in": "body",
"required": true,
"description": "mime type",
"type": "string",
"format": "alphanum",
"properties": null,
"items": null
},
"subject": {
"name": "subject",
"in": "body",
"required": true,
"description": "主题",
"type": "string",
"format": "",
"properties": null,
"items": null
},
"to": {
"name": "to",
"in": "body",
"required": true,
"description": "收件人列表",
"type": "array",
"format": "",
"properties": null,
"items": {
"name": "to.*",
"in": "body",
"required": true,
"description": "每个收件人",
"type": "object",
"format": "",
"properties": {
"address": {
"name": "to.*.address",
"in": "body",
"required": true,
"description": "单个收件人地址",
"type": "string",
"format": "email",
"properties": null,
"items": null
},
"name": {
"name": "to.*.name",
"in": "body",
"required": true,
"description": "单个收件人名称",
"type": "string",
"format": "",
"properties": null,
"items": null
}
},
"items": null
}
}
},
"items": null
},
2.json 2
body: {
'bcc': [{'address':'单个暗送人地址', 'name':'单个暗送人名称'}],
'cc': [{'address':'单个抄送人地址', 'name':'单个抄送人名称'}],
"content": '邮件内容',
"from": {'address':'发件人地址', "name":'发件人名称'},
"mimeType": "mime type",
"subject": "主题",
"to":[{'address':'单个收件人地址', 'name':'单个收件人名称'}]
}
因为时间关系,注解没写多详细
树形递归遍历就好了。
谢邀。。。。
讲道理,你的items应该是个数组,不然出不了你那个数据结构。