Questions tagged [python-jsonschema]
126 questions
1
vote
0 answers
JSON schema, check if sum of values exceeds 100
i am writing a json schema, that validates files based on the sum of numbers, stored in a property of an object, e.g. example below. The Sum of A and B can not exceed 100%. Is there a schema/function that allows this kind of specification?
Thanks…

user11752937
- 11
- 1
1
vote
1 answer
How to fix "DistributionNotFound: The 'jsonschema' distribution ..." in ipython
When in a virtual environment (venv) with jsonschema 3.0.1 installed, trying to import jsonschema from ipython results in the following error.
(venv) COMPUTER:prj user.name$ ipython …

cov
- 146
- 7
1
vote
1 answer
How to validate an array that can contain items that are objects of different types
I have a schema where I have an array (inside the transmit object) which could possibly have one of two options (A or B).
I have attached both the schema and sample data (that is actually getting validated, when it should have thrown an…

Bhakta Raghavan
- 664
- 6
- 16
1
vote
1 answer
Multi-stage $ref doesn't work with jsonschema version 3.0.1
It seems that jsonschema version 3.0.1 does not accept multi-stage schema using $refs (while it works with jsonschema version 2.6.0).
I have to make it work under several module versions simply because my code will be running on different computers…

Gabriel Georges
- 13
- 3
1
vote
1 answer
jsonschema validate by keys with different name or type
I am a in a transition from this type of jsons:
{
"id": 1,
"data": {
"item_number": "4",
...
}
}
to
{
"id": 1,
"data": {
"itemNumbers": [4],
...
}
}
and I would need a jsonschema that…

Amir
- 5,996
- 13
- 48
- 61
1
vote
1 answer
Is the Python jsonschema validator using a superset of the actual jsonschema?
When using Python jsonschema it is possible to define schemas and instances that cannot be expressed in valid JSON.
>>> import jsonschema
>>> schema = {
... "type": "object",
... "properties": {"1": {}, 2:{}},
... "additionalProperties":…

Stefano M
- 4,267
- 2
- 27
- 45
1
vote
0 answers
jsonschema validation fails to resolve "grandchild" local file references
Background:
I have multiple json schemas referring large same objects.
These objects are moved to a subdirectory.
In the example below, the following dependencies appear:
main_schema => positive_integer
main_schema => date
date =>…

Peter Zaitcev
- 316
- 1
- 14
1
vote
1 answer
How to compare json with pattern in python?
Json data:
{
"options": {
"name": "aaa",
"count": 20,
"a1": 30
},
"PC": {
"processor": "Intel",
"os": "windows"
}
}
Pattern:
{
"options": {
"name": "string",
"count": "integer",
"a1": "integer"
},
"PC":…

Hleb Krahotkin
- 11
- 2
1
vote
1 answer
JSONSchema not catching incorrect additional fields?
Using this schema, this file does not catch the name_en and legalName_en fields under parties/identifier, even though additionalProperties: false is specified on the identifier property.
This is with:
jsonschema schema.json -i file.json
on OSX,…

Richard
- 62,943
- 126
- 334
- 542
1
vote
0 answers
Python JSON schema mining
I need some step-by-step tutorial or some papers that I can learn how to create my own JSON schema mining tool. It would be great if someone can share sources or ideas. Thanks!

Umidjon Urunov
- 651
- 1
- 17
- 39
0
votes
1 answer
Programmatic (Python) format check in jsonschema
I have a schema where a property should comply to a pattern that only can be checked programmatically:
type: object
properties:
unit:
description: Unit of this column. Must be FITS conform.
type: string
where "FITS conformity" can be…

olebole
- 521
- 4
- 17
0
votes
2 answers
Generate json schema and validate json against the schema
How do I generate a JSON schema in Python for the below JSON and validate every json against the schema?
Requirements:
There is a type which can be CSV or JSON or JSON
There is a list of properties.
Each property has a key which is a column name…

Harish
- 565
- 1
- 12
- 34
0
votes
1 answer
Json validator validates successfully for any string inputs
Root Schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"deviceId": {
"description": "Unique ID of the device of type UUIDv4",
"type": "string",
"format": "uuid"
…

Daemon
- 1,575
- 1
- 17
- 37
0
votes
1 answer
Pros and cons of pydantic compared to json schemas
As far as I understand Pydantic and Json Schemas provide similar functionality - both can be used for validating data outputs.
I am interested to understand the pros and cons of using each one. A few questions I am interested in:
Are there any…

David Butler
- 143
- 1
- 10
0
votes
0 answers
How do I resolve a references with Python jsonschema RefResolver and delete attributes that doesn't match with schema
I am writing Python code to validate a dictionnary using a JSON schema and this schema is referenced by $ref some of them are a path of an other schema such like : ( "$ref": "./insurance-schema.json#/components/schemas/Name") and the others are the…

Nore Hamou tahra
- 11
- 1