1

如何确保 ID 号在此对象数组中是唯一的?我知道 uniqueItems 将确保整个对象在数组的顶层是唯一的,但是如果更改了任何其他设置,则 ID 号在多个元素中可以相同。

Draft-07 有可能吗?

我认为这可能是不可能的?有没有办法重组它来解决它?

{
    "type": "object",
    "properties": {
        "Partition Data": {
           "type": "array",                
           "uniqueItems" : true,
            "items": {
                "type": "object",
                "properties": {
                    "ID Number": {
                        "type": "object",                   
                        "properties": {
                            "value": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 4,
                                "default": 1
                            }
                        },
                        "required": [
                            "value"
                        ]
                    },
                    "Name": {
                        "type": "object",

                        "properties": {
                            "value": {
                                "type": "string",
                                "maxLength": 16
                            }
                        },
                        "required": [
                            "value"
                        ]
                    },
                    "Time Option 1": {
                        "type": "object",
                        "properties": {
                            "value": {
                                "type": "string",
                                "enum": [
                                    "None",
                                    "15 Seconds",
                                    "30 Seconds",
                                    "45 Seconds",
                                    "60 Seconds",
                                    "90 Seconds",
                                    "2 Minutes",
                                    "3 Minutes",
                                    "4 Minutes"
                                ],
                                "default": "30 Seconds"
                            }
                        },
                        "required": [
                            "value"
                        ]
                    },
                    "Bool Option 2": {
                        "type": "object",

                        "properties": {
                            "value": {
                                "type": "boolean",
                                "default": true
                            }
                        },
                        "required": [
                            "value"
                        ]
                    }
                }
            }
        }
    }
}

更多阅读......这个链接看起来很相似......它说它无法完成......真的吗? JSON 模式更深层次的对象唯一性

4

0 回答 0