gpt4 book ai didi

javascript - 从 JSON 模式创建 JSON 实例

转载 作者:搜寻专家 更新时间:2023-10-30 21:55:05 25 4
gpt4 key购买 nike

您好,我正在尝试从 JSON 模式创建 JSON 实例。

感谢 Typescript 回答,但感谢任何回答。

在 sample-schema.json 文件下方。我想创建一个函数来将模式转换为模式实例。

例如:sample-schema.json

{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"address": {
"type": "object",
"properties": {
"street_1": {
"type": "string"
},
"street_2": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string",
"enum": [
"AL",
"AK",
"AS"
]
},
"zip_code": {
"type": "string"
}
}
},
"birthday": {
"type": "string"
},
"notes": {
"type": "string"
}
},
"required": [
"last_name"
]
}

期望的输出:

{
"first_name": "",
"last_name": "",
"last_name": "",
"address": {
"street_1": "",
"street_2": "",
"city": "",
"state": "",
"zip_code": ""
},
"birthday": "",
"notes": ""
}

在调用该函数时,通过传递它必须生成 JSON 实例的架构。我在 Google 上进行了搜索,但所有结果都是从 JSON JSON 架构。

最佳答案

我从这个 json-schema-filter 找到了 javascript

关于javascript - 从 JSON 模式创建 JSON 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58231205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com