【发布时间】:2019-01-14 10:34:47
【问题描述】:
我正在寻找一个 Javascript 库来列出基于 Json Schema 的可能 Json 路径。
对于像下面这样的 json 架构,我想列出可能的 json 路径。
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Customer",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
},
"address": {
"type": "object",
"city": {
"type": "string",
},
"country": {
"type": "string",
}
}
}
}
可能的 Json 路径:firstName、lastName、age、address.city 和 address.country
【问题讨论】:
-
我认为您的架构无效。
address的架构应该有一个properties关键字,其中包含city和country。
标签: javascript json jsonschema jsonpath