JSON格式校验

16次阅读

共计 228 个字符,预计需要花费 1 分钟才能阅读完成。

json-schema

{
    "$schema":"http://json-schema.org/draft-04/schema",
    "type":"object",
    "properties":{
        "a":{
            "type":"array",
            "items":{
                "type":"object",
                "properties":{
                    "b":{"type":"integer"}
                }
            }
        }
    },
    "required":["a"]
}

以上规则可以校验以下的 json 数据

{
    "a":[
        {"b":9}
    ]
}

正文完
 0