小编ppa*_*ckk的帖子

如何确定一个 json 模式是否是另一个 json 模式的子集?

假设我有两个 json 模式 - 是否可以(在 python 或其他任何地方)确定一个模式是否是另一个模式的子集?

我正在寻找两个 json 模式上的函数,当且仅当第一个 json 模式接受的每个实例也被第二个 json 模式接受时,该函数才会返回 true。

对于一个超级简单的例子,假设我的模式是

int_schema = {'type': 'integer'}
num_schema = {'type': 'number'}
Run Code Online (Sandbox Code Playgroud)

那我就会

subset(int_schema, num_schema) = True
subset(num_schema, int_schema) = False
Run Code Online (Sandbox Code Playgroud)

不太关心这是 python,我更想知道 json-schema 是否支持这个。

python jsonschema python-jsonschema

5
推荐指数
1
解决办法
946
查看次数

标签 统计

jsonschema ×1

python ×1

python-jsonschema ×1