Is there any functionality support by any python library where we can pass one argument is jsonschema and second is json and validate it and return True or False?
(python库是否有任何功能支持,我们可以在其中传递一个参数jsonschema,第二个参数json并对其进行验证并返回True或False?)
I dont have any control on how the jsonschema will be? (我对jsonschema的控制方式没有任何控制权?)
example:
(例:)
json:
{
"id":1,
"name":"intel"
}
using ( https://www.liquid-technologies.com/online-json-to-schema-converter ) this to generate jsonschema.
(使用( https://www.liquid-technologies.com/online-json-to-schema-converter )生成jsonschema。)
jsonschema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}
if i will use https://jsonschema.net/ to generate jsonschema then
(如果我将使用https://jsonschema.net/生成jsonschema,那么)
jsonschema:
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/root.json",
"type": "object",
"title": "The Root Schema",
"required": [
"id",
"name"
],
"properties": {
"id": {
"$id": "#/properties/id",
"type": "integer",
"title": "The Id Schema",
"default": 0,
"examples": [
1
]
},
"name": {
"$id": "#/properties/name",
"type": "string",
"title": "The Name Schema",
"default": "",
"examples": [
"intel"
],
"pattern": "^(.*)$"
}
}
}
So the user can take any website to generate jsonschema and store into db through post api.
(因此,用户可以使用任何网站来生成jsonschema并通过post api存储到db中。)
And there is another post api where input json will validate against jsonschema which is stored by user. (还有另一个post api,其中输入json将针对用户存储的jsonschema进行验证。)
How to solve this scenarios ? (如何解决这种情况?)
Thanks in advance ! (提前致谢 !)
ask by VVK kumar translate from so