json schema标准

1,211 阅读1分钟

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://test.meepo.com.cn/schema/address.json",
    "title": "地址",
    "description": "描述一个用的的地址",
    "type": "object",
    "properties": {
        "province": {
            "type": "string"
        },
        "city": {
            "type": "string"
        },
        "district": {
            "type": "string"
        },
        "street": {
            "type": "string"
        },
        "extended": {
            "type": "string"
        },
        "point": {
            "$ref": "./geo.json"
        }
    }
}
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "id": "http://test.meepo.com.cn/schema/geo.json",
    "title": "位置",
    "description": "描述地理位置数据",
    "type": "object",
    "properties": {
        "latitude": {
            "type": "number",
            "title": "latitudeTitle",
            "description": "latitudeDescription",
            "minimum": -90,
            "maximum": 90
        },
        "longitude": {
            "type": "number",
            "title": "longitudeTitle",
            "description": "longitudeDescription",
            "minimum": -180,
            "maximum": 180
        }
    },
    "required": [
        "latitude", "longitude"
    ]
}
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://test.meepo.com.cn/schema/goods.jsong",
    "title": "goods",
    "description": "goods description",
    "type": "object",
    "properties": {
        "goods_title": {
            "type": "string"
        },
        "goods_description": {
            "type": "string"
        },
        "goods_content": {
            "type": "string"
        },
        "goods_price": {
            "type": "number"
        }
    }
}
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://test.meepo.com.cn/schema/language.json",
    "title": "language",
    "description": "language description",
    "definitions": {
        "language": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "language_code": {
                        "type": "string"
                    },
                    "language_title": {
                        "type": "string"
                    },
                    "language_description": {
                        "type": "string"
                    }
                },
                "required": [
                    "language_code", "language_value"
                ]
            },
            "minItems": 1
        }
    },
    "properties": {
        "zh-cn": {
            "$ref": "#/definitions/language"
        },
        "en": {
            "$ref": "#/definitions/language"
        }
    }
}