从 JSON 数据生成 JSON 模式的工具 [英] Tool to generate JSON schema from JSON data

查看:33
本文介绍了从 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.

这篇关于从 JSON 数据生成 JSON 模式的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆