检查JSON模式中的null

问题描述 投票:0回答:1

是否可以在模式中验证空值,例如[属性A为空值,那么将有一些必填字段]

例如:

"$schema": "http://json-schema.org/draft-04/schema#",
"id": "college.json#",
"title": "student",
"description": "syidentdetails",
"type": "object",
"properties": {
    "colleges": {
        "type": "array"

    },
    "school": {
        "type": "array"
    },

    "if":{
        "properties":{
            "college":["type":null]
        }
    },"then":{["required":"school"]}
}
java json jsonschema json-schema-validator
1个回答
0
投票

您需要用引号定义类型值,而不是实际的null

"type": "null"

© www.soinside.com 2019 - 2024. All rights reserved.