如何为 Map定义 Json 模式验证器
有人可以帮我定义以下 Json 的 Json 架构验证器吗?
{
"WorkflowName1": {
"WorkflowName": "WorkflowName1",
"NumberOfWorkers": 1,
"ActivityConfigs": {
"ActivityName1": {
"ActivityName": "ActivityName1",
"MaxTime": 200
}
}
},
"WorkflowName2": {
"WorkflowName": "WorkflowName2",
"NumberOfWorkers": 10,
"ActivityConfigs": {
"ActivityName1": {
"ActivityName": "ActivityName2",
"MaxTime": 2000
}
}
}
}
基本上,上面的 Json 是一个 Map
。
WorkflowConfig 具有 WorkflowName
、NumberOfWorkers
和 Map
。其中WorkflowName
和NumberOfWorkers
是必填的,Map
是可选的。
ActivityConfig 需要 ActivityName
和 MaxTime
。
我想为 schemaType 的上述结构定义 Json 模式:http://json-schema.org/draft-04/schema#
。
提前致谢。
Can someone please help me defining Json Schema validator for the below Json.
{
"WorkflowName1": {
"WorkflowName": "WorkflowName1",
"NumberOfWorkers": 1,
"ActivityConfigs": {
"ActivityName1": {
"ActivityName": "ActivityName1",
"MaxTime": 200
}
}
},
"WorkflowName2": {
"WorkflowName": "WorkflowName2",
"NumberOfWorkers": 10,
"ActivityConfigs": {
"ActivityName1": {
"ActivityName": "ActivityName2",
"MaxTime": 2000
}
}
}
}
Basically, above Json is a Map<String, WorkflowConfig>
.
WorkflowConfig has WorkflowName
, NumberOfWorkers
and Map<String, ActivityConfigs>
. Among these WorkflowName
and NumberOfWorkers
are mandatory, and Map<String, ActivityConfigs>
is optional.
ActivityConfig has ActivityName
and MaxTime
both required.
I want to define Json schema for the above structure for schemaType: http://json-schema.org/draft-04/schema#
.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下架构。您也可以在线尝试 json
架构验证器
这里我使用
additionalProperties
,因为此键名称中的Map
未固定,它可能是任何内容。You can use the below schema. And you can also try it in online json
schema validator
Here I'm using
additionalProperties
becauseMap<String, WorkflowConfig>
in this key name is not fixed it may be anything.