0

我正在寻找一个用于从 python 字典生成 json_schema 的 python 库

例如这本词典

fields = {
  "field1": {"title": "Field1 Title", "type": "string"},
  "field2": {"title": "Field2 Title", "type": "integer"},
  "field3": {"title": "Field3 Title", "type": "numeric", "description": "description", "multipleOf": 0.01},
}

应该处理到下一个json_schema:

{
    "title": "",
    "type": "object",
    "properties": {
        "field1": {
            "title": "Field1 Title",
            "type": "string"
        },
        "field2": {
            "title": "Field2 Title",
            "type": "integer"
        },
        "field3": {
            "title": "Field3 Title",   
            "description": "description",
            "type": "numeric",
            "multipleOf": 0.01,
        }
    },
    "required": ["field1", "field2"]
}
4

1 回答 1

-1

以 json 形式加载内容 -> json.loads(file)

于 2021-07-20T04:31:42.613 回答