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

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

问题描述:

我们有这个json模式草稿.我想获取我的JSON数据样本,并为JSON模式生成一个框架,该框架可以手动进行修改,添加诸如description,required之类的内容,而这些不能从特定的示例中推断出来.

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.