Questions tagged [python-jsonschema]

126 questions
26
votes
6 answers

How to set up local file references in python-jsonschema document?

I have a set of jsonschema compliant documents. Some documents contain references to other documents (via the $ref attribute). I do not wish to host these documents such that they are accessible at an HTTP URI. As such, all references are relative.…
Chris W.
  • 37,583
  • 36
  • 99
  • 136
7
votes
1 answer

Format Airflow Logs in JSON

I have a requirement to log the Apache Airflow logs to stdout in JSON format. Airflow does not seem to project this capability out of the box. I have found a couple python modules that are capable of this task, but I cannot get the implementation to…
7
votes
4 answers

Validate datetime value using python jsonschema

I'm using jsonschema to validate my python dictionary. I' trying to validate a datetime value but I'm not sure how to do it. Here's what I have so far, which results in an error because jsonschema doesn't have a datetime type: order = { "name":…
Johnny Metz
  • 5,977
  • 18
  • 82
  • 146
6
votes
1 answer

jsonschema extending and no additional properties

I am using jsonschema for validating entrytypes that describe how entries (of given types) are displayed. these entries can have pages and are separated into aspects. Both pages and aspects can be conditioned and I want to reuse a basic schema, even…
ramin
  • 928
  • 8
  • 12
5
votes
1 answer

How to validate json schema against metaschema in linux cli

I'm trying to validate my complex json schema definition file to be sure that there is no typo in the schema. I use the jsonschema script provided by python jsonschema library. I use meta-schema files downloaded from json schema specification…
eNca
  • 1,043
  • 11
  • 21
4
votes
0 answers

Generating Python Class from JSON Schema

I am trying to generate a new class in Python starting from a JSON Schema previously defined and created. Then I would like to use the autogenerated class to read a JSON file. My problem is that I manage to create the class from the schema using…
Zaba96
  • 41
  • 2
4
votes
1 answer

jsonschema dependentSchema not validating

I am trying to learn json schema, but something isn't working out for me. I'm trying to run the example from http://json-schema.org/understanding-json-schema/reference/conditionals.html#id4 for dependentSchemas, but it just doesn't validate. I'm…
SaBe
  • 43
  • 4
4
votes
0 answers

jsonschema expecting allOf to be of type 'object' or 'boolean'

I'm using PyPi jsonschema to validate my test schema. Here are the contents of test_schema.json: { "$schema": "https://json-schema.org/draft/2020-12/schema#", "title": "Single IV Run JSON Schema", "description": "Schema for single IV run…
4
votes
1 answer

How to determine if one json-schema is a subset of another?

Say I have two json-schemas - is it possible (in python or anywhere else) to determine if one is a subset of another? I am looking for a function on two json-schemas that will return true if and only if every instance accepted by the first…
3
votes
1 answer

How to implement conditional nested properties with JSON Schema

I have base json schema base.schema.json { "$id": "base.schema.json", "type": "object", "properties": { "remote_os": { "default": "Windows", "enum": [ "Linux", "Windows" ] } }, "required":…
curiousguy
  • 3,212
  • 8
  • 39
  • 71
3
votes
1 answer

JSON.parse error while writing json data into json file

I am trying to get JSON data from a localhost URL row by row and insert it into a JSON file. When I try to open the file, I receive an error that says Multiple JSON root elements. import urllib.parse import urllib.request, json import…
Devang Hingu
  • 578
  • 1
  • 6
  • 20
3
votes
2 answers

How to emulate a switch statement (switch-case) in a JSON Schema?

I'm using a JSON Schemajsonschema to validate JSON records. Here's an example schema. It has only two cases here, but imagine a similar scenario where it instead has a hundred cases laid out like these. { "$schema":…
liszt
  • 1,139
  • 1
  • 9
  • 17
3
votes
1 answer

python jsonschema remove additional and use defaults

I'm using the python jsonschema https://python-jsonschema.readthedocs.io/en/latest/ and I'm trying to find how to use default values and remove additional fields when found. anyone know how am I suppose to do it? or maybe have another solution to…
Elon Salfati
  • 1,537
  • 6
  • 23
  • 46
2
votes
2 answers

Extract which required key in JSON is missing from ValidationError

I try to validate JSON in python using jsonschema library. What I want to achieve is a dictionary with keys conststing of json keys causing trouble and messages from validator as values. There is no problem with type validation as it returns path to…
MrHutnik
  • 118
  • 3
  • 9
2
votes
0 answers

python jsonschema: Use "regex" module to validate "pattern"

I'm trying to use jsonschema for a schema which uses "pattern". However in this application, the "pattern" needs to be able to match unicode characters, which is not support by python's builtin "re" module. for example import jsonschema import…
user1751825
  • 4,029
  • 1
  • 28
  • 58
1
2 3
8 9