小编sur*_*abu的帖子

Json模式动态密钥验证

面对架构验证的问题.

架构:

{
    "type": "object",
    "$schema": "http://json-schema.org/draft-03/schema",
    "id": "#",
    "required": true,
    "patternProperties": {
        "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$": {
            "type": "object",
            "required": true,
            "properties": {
                "_from": {
                    "id": "_from",
                    "type": "string",
                    "required": true
                },
                "message": {
                    "type": "object",
                    "id": "message",
                    "properties": {
                        "detail": {
                            "type": "string",
                            "id": "detail",
                            "required": true
                        },
                        "from": {
                            "type": "string",
                            "id": "from",
                            "required": true
                        }
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

杰森:

{
    "tom@example.com": {
        "_from": "giles@gmail.com",
        "message": {
            "from": "Giles@gmail.com",
            "detail": "AnyonewanttomeetmeinParis"
        }
    },
    "harry@example.com": {
        "_from": "giles@gmail.com", …
Run Code Online (Sandbox Code Playgroud)

jsonschema json-schema-validator

11
推荐指数
2
解决办法
7723
查看次数

标签 统计

json-schema-validator ×1

jsonschema ×1