jsonschema - 使用对象的键验证属性值是否存在
问题描述
聪明的人群,
我已经有一个有效的 JSON Schema (v0.7) 来验证我的数据。这是有效 JSON 的示例:
{
"people": [
{ "id": 1, "name": "bob" },
...
]
}
现在我需要在其中添加一堆字符串:
{
"people": [
{ "id": 1, "name": "bob", "appears_in": "long_string_id_1" },
{ "id": 2, "name": "ann", "appears_in": "long_string_id_1" }
...
],
"long_strings": {
"long_string_id_1": "blah blah blah.....",
...
}
}
我需要的是:
- 键的值
appears_in
必须是long_strings
对象的键 - (可选)
long_strings
对象的键必须用作appears_in
键中的值
属性依赖关系很好,但似乎不能满足我的需求。
任何的想法?
而且这个问题不是重复的,因为我事先不知道这些值。
解决方案
对不起。您不能在 JSON 模式中执行此操作。您不能引用架构中的数据。
推荐阅读
- spring - 有没有办法从一个 restTemplate 交换响应中获取 cookie 并将其设置为另一个单独的请求?
- java - Spring Boot 应用程序在反向代理后面嵌入了 Tomcat,在请求 /contextPath 时不重定向到 https 而没有尾随斜杠
- javascript - ES6 中的 D3.js 饼图补间 - 未捕获的 TypeError
- asp.net-mvc - 如何在 MVC 视图中单击按钮时使用控制器方法填充文本区域?
- arduino - Arduino Uno 可以向 Cloud Firestore 发送数据吗?
- javascript - 为什么这里的“if”条件有效?
- jenkins - 当 Jenkins 跳过构建时,Github UI 显示失败的红色 X
- kubernetes - PODS 之间的负载均衡
- node.js - 如何找到在 7 天内访问我的网站超过 3 天的用户?
- python - 为什么它说退出状态1?