如何针对运行时JSON对象引用进行验证? [英] How to validate against runtime JSON object reference?

查看:57
本文介绍了如何针对运行时JSON对象引用进行验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于如下所示的示例JSON数据-

For a sample JSON data which looks like this -

{
    "children":{
        "Alice":{...},
        "Jamie":{...},
        "Bob":{...}
        // Any new child with a given unique name will be added to this object
    },
    childrenOrder:["Alice", "Bob", "Jamie"]
}

在相应的JSON模式中,我试图将"childrenOrder"数组中的有效值限制为来自运行时子项. 在官方的JSON Schema文档中,我没有任何引用运行时动态值的方法( http://json -schema.org/documentation.html ).

In the corresponding JSON Schema, I am trying to limit the valid values in "childrenOrder" array to be from the run time children keys. I didn't see any means of referring to runtime dynamic values in the official JSON Schema documentation (http://json-schema.org/documentation.html).

此刻是否有可能? 为了简洁起见,我省略了JSON Schema代码.如果人们认为有必要解决这个问题,我可以添加它.

Is this even possible at the moment? For the sake of brevity I omitted JSON Schema code. I can add it if folks think it is needed to address the question.

谢谢.

推荐答案

否,使用当前的JSON Schema规范是不可能的.但是,对于下一个版本的JSON Schema有一个建议,可以对此进行更改.

No it is not possible using the current JSON Schema specification. However, there is a proposal for the next version of JSON Schema that could change that.

https://github.com/json -schema/json-schema/wiki/%24data-(v5-proposal)

这篇关于如何针对运行时JSON对象引用进行验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆