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

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

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

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

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

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

此示例是手动编码的,因此可能存在错误。 是否有任何工具可以帮助我转换 JSON -> JSON 模式?

最佳答案

总结其他答案,这里是迄今为止提出的 JSON 模式生成器:

在线:

  • https://www.liquid-technologies.com/online-json-to-schema-converter (1 个输入)
  • http://www.jsonschema.net (1 个输入)
  • https://easy-json-schema.github.io (1 个输入)

Python:

  • https://github.com/gonvaled/jskemator (1 个输入,但允许迭代)
  • https://github.com/perenecabuto/json_schema_generator (1 个输入)
  • https://github.com/rnd0101/json_schema_inferencer (我认为有 1 个输入)
  • https://pypi.python.org/pypi/genson/ (多个输入)
  • https://pypi.python.org/pypi/skinfer (多个输入)

NodeJS:

  • https://github.com/Nijikokun/generate-schema (多个输入(传递对象数组))
  • https://github.com/easy-json-schema/easy-json-schema (1 个输入)
  • https://github.com/aspecto-io/genson-js (多个输入)

鲁比:

  • https://github.com/maxlinc/json-schema-generator (1 个输入)

https://stackoverflow.com/questions/7341537/

相关文章:

c# - 如何将 C# 匿名类型序列化为 JSON 字符串?

javascript - JSON 省略了 Infinity 和 NaN; ECMAScript 中

json - 在 Swift 中将字典转换为 JSON

python - 为什么我看到 "TypeError: string indices must be

javascript - 在 JavaScript 中将 JSON 字符串解析为特定的对象原型(pr

jquery - 为什么每个人都为 jQuery 选择 JSON 而不是 XML?

ios - 如何使用 NSJSONSerialization

json - 在 Unix shell 脚本中以可读的 JSON 格式显示 curl 输出

python - 将类实例序列化为 JSON

java - HttpServletRequest 获取 JSON POST 数据