从 JSON 数据生成 JSON 模式的工具

从 JSON 数据生成 JSON 模式的工具

问题描述:

我们有这个 json 模式 draft.我想获取我的 JSON 数据样本并为 JSON 模式生成一个骨架,我可以手动修改它,添加描述、必需等内容,这些内容无法从具体示例中推断出来.

We have this json schema draft. I would like to get a sample of my JSON data and generate a skeleton for the JSON schema, that I can rework manually, adding things like description, required, etc, which can not be infered from the specific examples.

例如,从我的输入example.json:

{
    "foo": "lorem", 
    "bar": "ipsum"
}

我会运行我的 json_schema_g​​enerator 工具并得到:

I would run my json_schema_generator tool and would get:

{ "foo": {
    "type" : "string",
    "required" : true,
    "description" : "unknown"
  },
  "bar": {
    "type" : "string",
    "required" : true,
    "description" : "unknown"
  }
}

这个例子是手动编码的,所以可能有错误.是否有任何工具可以帮助我转换 JSON ->JSON 架构?

This example has been coded manually, so it has maybe errors. Is there any tool out there which could help me with the conversion JSON -> JSON schema?

看到这个问题得到了相当多的赞成,我添加了新信息(我不确定这是不是新的,但我在时间)

Seeing that this question is getting quite some upvotes, I add new information (I am not sure if this is new, but I couldn't find it at the time)

  • The home of JSON Schema
  • An implementation of JSON Schema validation for Python
  • Related hacker news discussion
  • A json schema generator in python, which is what I was looking for.