1、$schema属性可以声明使用的schema版本,也可当做schema的标识,因为schema本身也是json,有了这个属性,就代表它不是一个普通的json而是schema。 2、title属性标识一下名称; 3、description属性对schema做详细的描述; 代码语言:javascript 代码运行次数:0 运行 AI代码解释 {"$schema":"http
可以用来实现类似“继承”的关系,例如我们定义了一个Schema_base,如果想要对其进行进一步修饰,可以这样来实现。 {"allOf":[Schema_base]"properties":{"other_pro1":{"type":"string"},"other_pro2":{"type":"string"}},"required":["other_pro1","other_pro2"]} Json数据既需要满足Schema_base,又要...
{ "title": "Match anything", "description": "This is a schema that matches anything.", "default": "Default value", "examples": [ "Anything", 4035 ] } 1. 2. 3. 4. 5. 6. 7. 8. 9. B、枚举关键字 枚举关键字enum是个应用比较广泛的Json Schema关键字,一般用于约束数据在枚举范围内进...
例一:涉及的关键字($schema、title、description、type、properties、required) { "$schema": "http://json-schema.org/draft-04/schema#", "title": "TestInfo", "description": "some information about test", "type": "object", "properties": { "name": { "description": "Name of the test", "...
description json schema文件的描述信息 object 参数描述 properties 定义待校验的json对象中,各key-value对中value的限制条件 required 待校验的json对象中,必须存在的key string 参数描述 maxLength 字符串类型数据的最大长度 minLength 字符串类型数据的最小长度 pattern 使用正则表达式约束字符串类型数据 enum 枚举约束 ...
{ "title": "Match anything", "description": "This is a schema that matches anything.", "default": "Default value", "examples": [ "Anything", 4035 ] } B、枚举关键字 枚举关键字enum是个应用比较广泛的Json Schema关键字,一般用于约束数据在枚举范围内进行取值。 { "type": "string", "enum"...
"enum": ["Street", "Avenue", "Boulevard"] } }, "required": ["number", "street_name"] } "$schema"、$id、title、description这 4 个字段先不看。 "type": "object",说明这个 JSON 的类型,通常为 object 或 array properties 关键字指定这个object有三个属性 number,street_name,street_type ...
description 描述 字符串 更加详尽的描述信息 default 默认值 无限制 定义默认值 3.2 通用验证关键字 关键字 描述 Schema有效值 json数据验证 enum 数据枚举 必须是数组,而且数组里面的元素至少必须有一个而且不能有重复值。 当json实例的值存在于enum列表中时,通过验证 type 定义类型 可以是字符串或者字符串数组,取...
JSON Schema Core Vocabulary $schema $id $ref $dynamicRef $anchor / $dynamicAnchor $defs 关键字 type title & description default examples deprecated readOnly & writeOnly $comment enum const 媒体类型关键字 contentMediaType contentEncoding 组合模式 ...
这就是 JSON Schema 的用武之地。以下 JSON Schema 片段描述了上面第二个示例的结构。现在不要太担心细节。它们将在后续章节中进行解释。 { "type": "object", "properties": { "first_name": { "type": "string" }, "last_name": { "type": "string" }, "birthday": { "type": "string", ...