相关疑难解决方法(0)

在 json 模式中定义键值对的正确方法是什么

我如何在 json 模式中定义键值对对象(“正确”的方式)?

我想定义这个:

"id" : 99,
_info : {
    "name" : "somename",
    "href" : "someUrl"
}
Run Code Online (Sandbox Code Playgroud)

以下两项是否准确?:

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"
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

2)

{
    "type": "object",
    "name": "MyObj",
    "properties": {
        "id": {
            "type": "integer",
        "_info": {
            "type": "object",
            "additionalProperties": {
                "type": …
Run Code Online (Sandbox Code Playgroud)

schema json json.net jsonschema

8
推荐指数
1
解决办法
6590
查看次数

标签 统计

json ×1

json.net ×1

jsonschema ×1

schema ×1