135 questions
5
votes
7
answers
1k
views
Using Python how do I validate JSON against a JSON schema in a streaming fashion, e.g., not loading the whole object in memory?
I have a large JSON that I do not want to load into memory. I would like to validate it against a JSON schema in a streaming fashion. All libraries I could find so far, only validate completely loaded ...
0
votes
1
answer
37
views
python jsonschema not recognising `"allOf"` with `$ref`
I have some jsonschema for a dictionary Resource, containing a $defs PartialResource.
{
"title": "resource",
"type": "object",
"allOf": [
...
1
vote
1
answer
63
views
JSON Schema: How to Check array A contains at least all value of array B
I expect array A to contain at least all the elements of attribute array B.
Here are some examples:
// valid
{
"A": [1,2,3],
"B": [1,2]
}
// valid
{
"A": [1,2],
"B&...
0
votes
1
answer
359
views
How do I make a custom jsonschema keyword (vocabulary) that can be used anywhere in another schema?
I am trying to create a custom jsonschema keyword for some basic evaluation. An example would be "parallelArrays" where the provided lists would be checked to make sure they are the same ...
0
votes
1
answer
60
views
Import variable as dependency from the main YAML schema to a sub-schema
I have a YAML schema splitted in two files. Like this:
main.yaml
type: object
properties:
a:
description: variable a
type: string
b:
description: variable b
$ref: support.yaml
and ...
1
vote
2
answers
261
views
Need to know the difference between contains and items keyword of json schema validation
i am using jsonschema validation library of python to perform the schema validation below are the code snippet used along with the schema version and sample json data. my question is when i am using ...
1
vote
1
answer
714
views
pydantic model with fields that have dependent allowable values
I have a pydantic model that has fields with dependent allowable values which I would like to be properly represented in the JSON Schema. Think of this as a category / subcategory relationship like:
...
0
votes
1
answer
73
views
Double nested JSON schema
I have one top-level schema
content.json
{
"title": "Program content schema",
"$id": "https://example.com/schemas/program",
"type": "...
3
votes
2
answers
3k
views
Seemingly unrelated 'rpds.rpds' error when importing Python library onto AWS Lambda
I've been trying to move some python code I've written into AWS Lambda. It's a CSV validator that uses the 'pycsvschema' library, and works perfectly on my local PC. I had to do some finicking with ...
1
vote
1
answer
440
views
JSON schema anyOf properties required with a specific error message
I'm trying to implement JSON validation using Python jsonschema library.
I want to have at least one of the three properties to be required in my JSON.
I'm using anyOf subschema to achieve that.
This ...
0
votes
2
answers
1k
views
JSON Schema referencing in array items from another file
I have two JSON schemas - publisher and article, such that there could be multiple articles in a single publisher.
This is the article schema (in a.json):
{
"$schema": "https://json-...
2
votes
2
answers
697
views
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 ...
0
votes
1
answer
375
views
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.
...
3
votes
0
answers
235
views
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 ...
0
votes
2
answers
3k
views
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.
...
0
votes
1
answer
790
views
Json validator validates successfully for any string inputs
Root Schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"deviceId": {
"description": &...
7
votes
1
answer
8k
views
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 ...
0
votes
2
answers
151
views
Can I validate that nodes exist that edges in a graph point to with JSON SCHEMA?
I want to describe a network graph of vertices and edges with JSON Schema.
An example JSON could look like this:
{
"V": [
"1",
"2",
"3"
],
&...
0
votes
1
answer
196
views
Best way to pin point validation error cause with python jsonschema if/then/else statements
I am a big fan of python jsonshema. I recently found the if/then/else options which I really like.
However, I have a huge problem with it. Let's say I have:
{
"required": ["PROP1&...
1
vote
1
answer
1k
views
json-schema - reference all nested properties as string regardless of name
I am trying to reference all nested properties as string regardless of name.
An example of the data looks like this (except with a bunch of columns):
[
{
"var_1": "...
1
vote
2
answers
2k
views
Json Schema validation: should raise Exception when there are unrecognized fields
A simple example:
import json
from jsonschema import validate
schema = {
"type" : "object",
"properties" : {
"description" : {"type" :...
0
votes
1
answer
507
views
Can't reference a subschema in json schema
So I am working on this problem where I have to validate the json schema based on some conditions. If xy-ac is in the schema then I want source to be present there as well. It is required. Currenlty, ...
1
vote
0
answers
406
views
Validating flattened json keys and schemas
Im trying to find a way to validate flattened json-keys. For example, lets say I have a schema defined as below:
{
"$schema":"http://json-schema.org/draft-04/schema#",
"...
1
vote
1
answer
49
views
Jsonstatdataset rename
I am trying to read a table from the Central Statistics Office for Ireland. I am reading it into a collection and successfully displaying the first dataset
dataset = collection.dataset(0)
print(...
0
votes
0
answers
835
views
Pydantic not playing nicely with Json Schema oneOf
I'm trying to create a pydantic model of a json schema I'm using with oneOf. The basic schema is as follows:
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
&...
0
votes
2
answers
1k
views
JSON schema requiring patternProperties
I'm looking for help in defining the JSON schema which would validate the below sample JSON. I don't know the country codes before hand, so they can be any country code actually. In other words, I ...
3
votes
2
answers
925
views
Set defaults from JSON schema during validation
I try to make a validator that would set defaults from a JSON schema during validation.
I found this question: Trying to make JSON Schema validator in Python to set default values and adjusted it a ...
0
votes
1
answer
1k
views
How to validate an array of custom objects with jsonschema in Python
I have this primary schema for each one of my data points:
data_schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
...
0
votes
1
answer
882
views
JsonSchema logging deprecated warnings to schema
I want to log a warning when a deprecated property is being used or when the value of that property is in a deprecated format. I'm using the deprecated annotation for that but it doesn't do anything. ...
2
votes
2
answers
3k
views
ValidationError assertion not working when pytest shows the same values
I'm writing a unit test whereby I want to assert that the error I get:
<ValidationError: "'a list' is not of type 'array'">
is equal too
assert ValidationError(message="'a list' ...
2
votes
1
answer
903
views
Loading Valid Values from Another JSON File
I would like to create a JSON schema that defines two entities: region and country.
The JSON schema for country is as follows:
{
"$id":"https://example.com/arrays.schema.json",
...
0
votes
0
answers
1k
views
Python-jsonschema validation of Pydantic class
So we're using pydantic and python-jsonschema to validate user input. Pydantic for internal validation, and python-jsonschema for validation on the portal. And I've come across an interesting issue, ...
0
votes
1
answer
695
views
Json schema for a complex JSON?
I have a json that uses object of objects in place of an array, to easily search through the data with json keys.
How can I validate this against a schema, without hardcoding the key into the schema ? ...
0
votes
1
answer
2k
views
json-schema : Get a list of additionalProperties?
Is it possible to get a list of all additionalProperties found by json-schema ?
For example, if my schema looks like this :
{
"type": "object",
"properties": {
&...
1
vote
0
answers
1k
views
How to generate all test cases from a JSON schema
I am developing a system where we create documents that are created from json-files. The json files are described by a json schema of the following kind, where a key either could have a static default ...
0
votes
1
answer
1k
views
Python - Validate all rows in JSON file against schema
I am trying to validate all rows in my JSON data file against the schema without looping through each data entry in the JSON file.
However when just passing in the entire JSON file no validation ...
1
vote
2
answers
3k
views
Best Match for Validation error with oneof or anyof
I am trying to get proper validation error from oneof or anyof pattern. I have json schema with two or more oneof/anyof condition as mentioned below:
json_schema = {
"type": "...
0
votes
1
answer
710
views
Error handling for json-schema redefined type_checker in python
I'm using json-schema to validate a schema. I wanted to customize the date-time type. So, redefined the type accordingly and extended the validator. But, it's not returning the error the way I'm ...
2
votes
1
answer
1k
views
How to validate a list of dictionaries using jsonschema with Python
I have a list of dictionaries like this:
list_of_dictionaries = [{'key1': True}, {'key2': 0.2}]
And I want to validate it using jsonschema package.
I created a schema like this:
schema = {
"...
6
votes
0
answers
2k
views
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 ...
3
votes
1
answer
2k
views
Python tools/libraries to validate a JSON schema [closed]
Are there any python libraries or tools that check if a JSON schema is valid?
I do not want to validate an instance against a JSON schema, but I would like to check if the JSON schema itself is valid ...
0
votes
1
answer
357
views
Can I import table in a JSON Schema validation?
I am writing a JSON schema validation. I have an ID field whose values are imported from a table in SQL Server. These values are large and are frequently updated, so is there a way to dynamically ...
4
votes
1
answer
2k
views
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 ...
1
vote
1
answer
3k
views
JSON Schema relative references resolution
I am trying to define a valid JSON Schema and I am not sure how to structure the reference ("$ref") values when referenced components are in sub-directories. I have read (at length) the ...
1
vote
0
answers
169
views
I want to Save Maps in JSON File from Selenium Scrape data
I scraped a website and I get all the data from it and I want store it in json file
so I could use it as an API the problem is that when it tries to write maps in JSON file it get duplicated because ...
6
votes
1
answer
2k
views
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 ...
2
votes
0
answers
414
views
jsonschema - python - How to validate a schema containing a ref
I have been trying so hard to figure out how to get a schema that is nested in a definition with a $ref. If I hard code the jsonschema object I have no problems whatsoever, however I need to use a ...
0
votes
1
answer
747
views
How to create dynamic form using JSONSchemaField based on ID passed from the form request in Django?
The form is rendering properly if I give ID as a static value in forms.py, it wont render properly when I use the ID that I got from form call
views.py
def assetAddJsonView(request,pk):
form = ...
1
vote
1
answer
712
views
How to validate sub-schemas based on value in parent schema
I am trying to validate a JSON schema using jsonschema lib.
scenario:
I need to make sure if a specific value in a property is sent in the parent object, the child(sub-schema) should also get the same ...
1
vote
1
answer
575
views
JSON Schema enum with maximum and minimum
I have a JSON object like this.
{
"test": bla bla bla
}
This test can be a number between 0 and 120 or an empty string. I want to validate this JSON object using a JSON schema like this.
{...