Questions tagged [jsonschema]

A JSON Schema is a JSON document (an object) which defines constraints on what other JSON documents (the instances) should obey; it can also be used to interpret instances so as to provide links to external resources (hyper schema).

JSON (JavaScript Object Notation) Schema defines the media type application/schema+json, a JSON based format for defining the structure of JSON data.

JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

References:

For the latest Internet Draft documents, see the specification section of the website.

3348 questions
12
votes
3 answers

JSON Schema conditional: require and not require

I'm trying to implement this condition: if a particular property exists, then another property is required; but if it does not exist, another one is not required. Also, in JSON schemas, can we use not in dependencies? Here is a sample schema var…
hoj
  • 158
  • 1
  • 1
  • 8
12
votes
4 answers

make json schema pattern case insensitive

in my json schema i made a definition for "colors" like this { "colors": { "type":"string", "pattern":…
12
votes
1 answer

JSON Schema conditional: field is required based on value of another field

I'm trying to implement this condition: field is required based on value of another field i.e. if request with "index":"true" exists then "id" element required: true. Here is a sample schema: { "$schema":…
Artur Burnos
  • 177
  • 1
  • 2
  • 9
12
votes
2 answers

JSONSchema split one big schema file into multiple logical smaller files

I want the common parts of json schema to be captured in a file and then reference this file from the main schema file. So basically instead of 1 big json schema file, multiple files which reference each other. Am using json-schema-validator lib to…
nishant
  • 955
  • 2
  • 11
  • 27
11
votes
2 answers

How to conditionally forbid properties based on presence of other properties in JSON Schema?

In my schema I declared these properties: "index_name": { "type": "string", "examples": ["foo-wwen-live", "foo"] }, "locale": { "type": "string", "examples": ["wwen", "usen", "frfr"] }, "environment": { "type":…
Maks Babarowski
  • 652
  • 6
  • 16
11
votes
1 answer

How can I compare two values using jsonschema?

I have two parameters, say number_1 and number_2. The value of number_2 should be greater than the value of number_1. How can this be done in jsonschema?
Chandana
  • 111
  • 1
  • 4
11
votes
1 answer

JSON schema + relative JSON-pointers: how to verify "confirm password" field

Here's my JSON Schema: { "required": [ "username", "password", "confirmPassword" ], "properties": { "username": { "minLength": 3, "type": "string" }, "password": { "minLength": 6, "type":…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
11
votes
5 answers

NodeJS validation library for json objects

I need to validate some object in my NodeJS app. I have already used an awesome library express-validator, it works perfectly, but now I need to validate different object, not only requests and as far as express validator leverages validator…
user4671628
11
votes
2 answers

Remove properties from JSON object not present in schema?

I am using Python's jsonschema to validate JSON files against a schema. It works great. But now I need to remove any properties from my JSON that are not present in the schema. I know that according to the JSON Schema docs, I can set the…
Richard
  • 62,943
  • 126
  • 334
  • 542
11
votes
1 answer

How do I do a nested list (array) of schema references in json schema that isn't a dictionary

So I have a similiar question (see: How do I do a nested list (array) of schema references in json schema), but now my structure is changed a little and can't seem to get it to validate. data = { 'VIN': '1234567', 'Vehicle color': blue, …
xamox
  • 2,599
  • 4
  • 27
  • 30
11
votes
4 answers

Validate JSON schema compliance with Jackson against an external schema file

I would like to use the Jackson library (https://github.com/FasterXML/jackson) to deal with JSON files in Java, which are described by a JSON schema file. Now, I would like to validate, if a parsed JSON complies with a JSON schema file, which is…
madison54
  • 743
  • 2
  • 8
  • 19
11
votes
2 answers

JSON schema: date greater than an other

I've a json schema like this: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Operation", "description": "The schema of an operation", "type": "object", "properties": { "id":{ "description": "Unique identifier…
Djiby Thiaw
  • 213
  • 4
  • 11
11
votes
3 answers

How to find parent Json node while parsing a JSON

I am parsing a JSON Stream using Jackson. API that I am using is ObjectMapper.readTree(..) Consider following stream: { "type": "array", "items": { "id": "http://example.com/item-schema", "type": "object", …
Optional
  • 4,387
  • 4
  • 27
  • 45
11
votes
2 answers

JSON schema validator library in Java

I have a restful web service(JAVA) which has to accept JSON requests. I have to first validate this JSON against a JSON schema that I have. I'm not sure what is the best JAVA library to validate JSON again JSON schemas. I have used…
user1457881
  • 321
  • 2
  • 3
  • 10
10
votes
1 answer

python data structure validation using Validator (or something similar)

I'm dealing with data input in the form of json documents. These documents need to have a certain format, if they're not compliant, they should be ignored. I'm currently using a messy list of 'if thens' to check the format of the json document. I…
jay_t
  • 3,593
  • 4
  • 22
  • 27