【发布时间】:2021-01-20 06:17:33
【问题描述】:
我在我的应用程序中使用 Java。我想将多级嵌套的json和表单处理为键值对。
映射格式 1 定义为 Map
{
"first_name": {
"type": "string"
},
"date_of_birth": {
"type": "date"
},
"last_name": {
"type": "string"
},
"video": {
"type": "nested",
"properties": {
"id": { "type": "integer" },
"title": { "type": "string" },
"description": { "type": "string" }
}
},
"address": {
"type": "object",
"properties": {
"work": {
"type": "string"
},
"home": {
"type": "string"
}
}
}
}
预期结果:
{
"first_name": "string" ,
"date_of_birth": "date",
"last_name": "string",
"video.id": "integer",
"video.title": "string",
"video.description": "string",
"address.work": "string",
"address.home": "string"
}
映射格式2定义为Map
{
"first_name": "string"
"date_of_birth": "date"
"last_name": "string"
"video": {
"id": "integer",
"title": "string",
"description": string",
"mpeg": {
"format": "string",
"name": "string"
}
},
"address": {
"work": "string",
"home": "string"
}
}
预期结果:
{
"first_name": "string",
"date_of_birth": "date",
"last_name": "string",
"video.id": "integer",
"video.title": "string",
"video.description": "string",
"video.description": "string",
"video.mpeg.format": "string",
"video.mpeg.name": "string",
"address.work": "string",
"address.home": "string"
}
如何在 Java 11 中使用 Map 获得上述预期结果?
【问题讨论】: