JSON Schema

本文详细介绍了JSON Schema,一种用于验证JSON文档的规范,包括关键字解释、使用示例和综合案例。涉及的关键字有""type"
摘要由CSDN通过智能技术生成

JSON Schema:用于描述JSON文档的媒体类型

官方文档:http://json-schema.org/

关键字的文档:http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.5

 

首参考博客:https://blog.csdn.net/xiong9999/article/details/53688336

(说明了关键字的意义)

 

github文档:https://github.com/json-editor/json-editor

(待学习 $rel引用, format,checkbox 怎么变成选框,enum枚举  有时间需要学习)

参考以下博客:

博客:https://blog.csdn.net/taiyangdao/article/details/77865622

博客:https://www.cnblogs.com/fengxiongZz/p/6687058.html

博客:https://blog.csdn.net/bystarlight/article/details/72467822

博客:https://www.jianshu.com/p/8278eb2458c4?winzoom=1

 

 

关键字:

验证数组关键字:

定义了 “type”:“array”后,必须有 

(1)items  --》代表数组的每一项

(2)maxItems  --》数组的最大长度

(3)minItems  --》数组的最小长度

(4) uniqueItems --> 布尔值, 为 true时表示数组的每一项唯一性

 

 

 

编写的第一个Schema文件:

{
   "$schema": "http://json-schema.org/draft-04/schema#",
   "defaultProperties":[
        "hero",
        "recommendSkin",
        "skin"
    ],
    "properties":{
        "hero":{
            "type":"array",
            "id":"/properties/hero",
            "title": "hero",
            "description":"11",
            "items":{
                "type": "object",
                "id": "/properties/hero/items",
                "defaultProperties":["actUrl", "hotTag","id", "imgUrl","name","title"],
                 "properties":{
                     "actUrl":{
                          "type": "string",
                          "id": "/properties/hero/items/actUrl",
                           "title": "actUrl",
                           "default": "http://lol.qq.com/act/a20180514pyke/index.html",
                           "description": "acturl  Notknow"
                     },
                      "hotTag":{
                          "type": "string",
                          "id": "/properties/hero/items/hotTag",
                           "title":

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值