如何在 json 模式中定义键值对对象(“正确”方式)?
我想定义这个:
"id" : 99,
_info : {
"name" : "somename",
"href" : "someUrl"
}
以下两项是否准确?:
1)
{
"type": "object",
"name": "MyObj",
"properties": {
"id": {
"type": "integer"
},
"_info": {
"type": "array",
"items": {
"type": "object"
"properties": {
"key": {
"type": "string",
"description": "key"
},
"value": {
"type": "string",
"description": "the value"
}
}
}
}
}
}
2)
{
"type": "object",
"name": "MyObj",
"properties": {
"id": {
"type": "integer",
"_info": {
"type": "object",
"additionalProperties": {
"type": "string",
"description": "string values"
}
}
}
}
完成此任务的正确方法是什么,人们会知道架构是什么以及对象在序列化/反序列化时会是什么样子?