I want to know whether there is a method in which I can generate sample json output based on a json schema input.

for example :-

input =>

{
"title": "Example Schema",
"type": "object",
"properties": {
    "firstName": {
        "type": "string"
    },
    "lastName": {
        "type": "string"
    },
    "age": {
        "description": "Age in years",
        "type": "integer",
        "minimum": 0
    }
},
"required": ["firstName", "lastName"]
}

output => 

{     
  "firstName" : "RandomFirstName",
   "lastName" : "RandomLastName"
}

I have a large Json Schema with plenty of validations so to generate a sample valid json I could either create one manually using either Java or just a type it into a file. Is there a better way available ?

推荐答案

You can try the JSON Schema Faker. It will take a schema and generate/output a JSON object that will validate against the schema.

Json相关问答推荐

时间序列的Vega Lite分组条形图

如果主对象中已存在属性,则不应在Jolt中引用次对象

如何使用jq使用子值对象的键对json对象进行分组

Jolt Spec 跳过数组中的第一个元素

在 PowerShell 中通过 aws cli 创建 cloudwatch alert 时出现字符串解析错误

条件性构建/修改嵌套对象数组

如何强制仅有一个元素的数组在JSON中生成方括号

使用Powershell将JSON文件加载到SQL Server表格

为什么解析的字典相等而腌制的字典不相等?

我无法将来自 API 的数据显示到 FlatList 中,但我在 console.log 中看到了它.问题是什么?

Vue 3如何将参数作为json发送到axios get

使用 ConvertFrom-Json 后,Powershell 访问 JSON 中的嵌套对象

如何从 JSON 中获取数据并通过 vb6 在网格中显示

缺少所需的请求正文内容:org.springframework.web.method.HandlerMethod$HandlerMethodParameter

如何从 JSON 对象中获取日期

json和空数组

在 Android 中使用带有 post 参数的 HttpClient 和 HttpPost

如何安装 json gem - 无法构建 gem 原生扩展(mac 10.10)

将 JSON 模式转换为 python 类

Backbone.js 模型与集合