json - JSON模式-递归模式定义

标签 json jsonschema

我有一个JSON模式

{
    'description': 'TPNode',
    'type': 'object',
    'id': 'tp_node',
    'properties': {
        'selector': {
            'type': 'string',
            'required': true
        }, 
        'attributes': {
            'type': 'array',
            'items': {
                'name': 'string',
                'value': 'string'
            }
        },
        'children': {
            'type': 'array',
            'items': {
                'type': 'object',
                '$ref': '#'
            }
        },
        'events': {
            'type': 'array',
            'items': { 
                'type': 'object',
                'properties': {
                    'type': {
                        'type': 'string'
                    },
                    'handler': {
                        'type': 'object'
                    },
                    'dependencies': {
                        'type': 'array',
                        'items': {
                            'type': 'string'
                        }
                     }
                 }
            }
        }
    }
}


我要在children属性中表示的是,它是具有相同精确模式的对象数组。这是描述它的正确方法吗?

最佳答案

使用您需要引用的架构的id

'$ref': 'tp_node'


看这里:
http://json-schema.org/latest/json-schema-core.html#anchor30

关于json - JSON模式-递归模式定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20752716/

相关文章:

json - Blackberry 10 级联 - 检查 Internet 连接

javascript - 如何从选项 select - json 对象中获取特定值

json - 如何让 Visual Studio 2013 使用自定义 JSON 架构?

typescript - 如何使用 webpack 将 json 模式动态加载到 typescript

javascript - JSON 模式 + 相关 JSON 指针 : how to verify "confirm password" field

php - 从对象末尾删除 "\ufeff"-> Google+ API json 结果中的内容

ruby-on-rails - JSON、response_with 和嵌套资源路由错误?

ios - Swift IAP 稍后从 json 响应中获取latest_receipt_info 值

c# - 如何使用 Json.NET.Schema 要求属性?

c# - Newtonsoft JSON 架构忽略反序列化验证