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
18
votes
1 answer

JSON schema for dynamic properties

i have an object in which the "key" of the property will be set dynamically... what is the right way of defining this in a JSON Schema? This is what my object looks like { "column_definitions": [ { "Field_1": {      "type":…
Gustavo
  • 685
  • 3
  • 7
  • 17
18
votes
1 answer

JSON Schema away to specify an "any"-type schema with certain required fields

Let's say I have the following JSON Schema { "name":"Product", "type":"object", "properties":{ "id":{ "type":"number", "required":true }, "name":{ "description":"Name of the product", "required":true }, …
Bernardo Cunha
  • 443
  • 1
  • 5
  • 10
17
votes
1 answer

Python - Cerberus, jsonschema, voluptous - Which one will be appropriate?

I am developing a small RESTful web application in python and using JSON as interface. The application accepts JSON data and needs to validate them against a schema. The schema may be very strict or flexible depending on the request. Also, the…
17
votes
3 answers

Referencing a local relative file in a JSON Schema?

I am building a JSON for a REST web service. The schema however has grown to over 1300 lines and I want to split it up across multiple files. I am unit testing my schema against a folder of JSON sample responses using json-schema-validator version…
Sled
  • 18,541
  • 27
  • 119
  • 168
17
votes
2 answers

JSON schema to enforce array contents

Hi all and thanks in advance. I am attempting to create a JSON schema to enforce an array to contain one A and B object and N C objects, where A and B are C objects and N is an integer inclusively between 0 and infinity. Therefor : [A, B] [A, B,…
Dawson
  • 4,391
  • 2
  • 24
  • 33
17
votes
3 answers

Java/Android - Validate String JSON against String schema

I am having trouble finding the most simple way to validate a JSON String against a given JSON-schema String (for reference, this is in Java, running in an Android app). Ideally, I'd like to just pass in a JSON String and a JSON-schema String, and…
svguerin3
  • 2,433
  • 3
  • 29
  • 53
16
votes
4 answers

Jackson: How can I generate json schema which rejects all additional content

I want to generate JSON schema where "additionalProperties" : false will be applied for all classes which I have. Suppose I have following classes: class A{ private String s; private B b; public String getS() { return s; } …
Beno
  • 945
  • 11
  • 22
16
votes
3 answers

Form fields lose focus when input value changes

I'm trying to build a form with conditional fields from a JSON schema using react-jsonschema-form and react-jsonschem-form-conditionals. The components I'm rendering are a FormWithConditionals and a FormModelInspector. The latter is a very simple…
Dónal
  • 185,044
  • 174
  • 569
  • 824
16
votes
2 answers

How do I mark a property in JSON schema as deprecated?

I have a JSON schema that defines JSON documents. There's an use case where we want to deprecate a particular attribute in favour of a new attribute being introduced and want to mark the old attribute as deprecated. Does JSON schema support that?
Abhay Dubey
  • 549
  • 2
  • 7
  • 18
16
votes
1 answer

JSON Schema oneOf properies filled

How to set JSON Schema rule to say that exactly one of the properties have to be set and is required? I tried various ways to solve it like: { "id":"#", "required":true, "additionalProperties":true, "type":"object", "properties":{ …
Lunack
  • 343
  • 1
  • 5
  • 14
15
votes
2 answers

How to validate JSON schema in java?

I try to check user detail object with use JSON schema. But I don't know how to check JSON object in Java. My Schema: { "type" : "object", "properties" : { "first_name" : { "type" : "string" , …
Obeth Samuel
  • 590
  • 1
  • 6
  • 18
15
votes
1 answer

json-schema-validator custom message

I am using json-schema-validator2.2.6 library to validate my json against json schema. The problem is that it gives generic error messages that are not relevant to me. I want to send custom message or code to user. Do we have any option like this…
New Bee
  • 1,007
  • 4
  • 18
  • 34
15
votes
2 answers

How to make a "patternProperty" required in JSON Schema (Ruby)

Consider the following JSON : { "1234abcd" : { "model" : "civic" "made" : "toyota" "year" : "2014" } } consider another JSON : { "efgh56789" : { …
EasyQuestions
  • 327
  • 1
  • 10
  • 23
15
votes
2 answers

Json schema dynamic key validation

Facing an issue with schema validation. schema : { "type": "object", "$schema": "http://json-schema.org/draft-03/schema", "id": "#", "required": true, "patternProperties": { "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$": { …
suri babu
  • 223
  • 1
  • 2
  • 8
15
votes
4 answers

Python: jsonschema package to validate schema and custom error messages

Given this schema: { "type": "object", "properties": { "account": { "type": "object", "required": ["id"], "properties": { "id": {"type": "number"} } }, …
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189