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
25
votes
4 answers

setting required on a json-schema array

I am trying to figure out how to set required on my json-schema array of objects. The required property works fine on an object just not an array. Here is the items part of my json schema: "items": { "type": "array", …
ipengineer
  • 3,107
  • 7
  • 33
  • 37
24
votes
6 answers

set Jackson ObjectMapper class not to use scientific notation for double

I am using a library com.fasterxml.jackson library for JsonSchema, I am creating an IntegerSchema object, when I set range for integer schema using below code: main(){ IntegerSchema intSchema = new IntegerSchema(); // setMaximum accepts…
Abhij
  • 1,222
  • 4
  • 19
  • 37
24
votes
4 answers

Can JSON schema enums be case insensitive?

JSON Schema enums JSON Schemas feature enums, which impose a constraint on the values of a string type: { "type": "array", "items": [ { "type": "number" }, { "type": "string" }, …
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
24
votes
4 answers

Validate JSON against JSON Schema C#

Is there a way to validate a JSON structure against a JSON schema for that structure? I have looked and found JSON.Net validate but this does not do what I want. JSON.net does: JsonSchema schema = JsonSchema.Parse(@"{ 'type': 'object', …
Shaun Groenewald
  • 866
  • 1
  • 17
  • 34
24
votes
2 answers

How do I validate incoming JSON data inside a REST service?

A rest service needs to validate all incoming json data against a json schema. The json schemas are public accessible and can be retrieved via http requests. I'm using the jackson-framwork for marshaling and unmarshaling between java and json. So…
My-Name-Is
  • 4,814
  • 10
  • 44
  • 84
23
votes
1 answer

Custom Properties in JSON Schema

Is it valid to extend a JSON schema with custom properties? The reason I am asking is, because I am using a schema to also render a form for the JSON the schema describes (each property described in the schema is used as a form element with label…
bbop99
  • 1,625
  • 1
  • 11
  • 25
23
votes
3 answers

JSon schema and Inheritance

I have searched on json schema with java bindings with inheritance and all searches led me to the usage of "allOf". Using allOf would potentially solve my problem, but I am wondering if there is a construct in json schema that I can use which will…
user3748879
  • 255
  • 1
  • 2
  • 7
23
votes
2 answers

JSON schema $ref does not work for relative path

I have 3 schemas: child schema: { "title": "child_schema", "type": "object", "properties": { "wyx":{ "type": "number" } }, "additionalProperties": false, "required": ["wyx"] } parent schema: { …
ahri
  • 387
  • 1
  • 5
  • 11
23
votes
4 answers

JSON Schema - Recursive Schema Definition

I have a JSON Schema { 'description': 'TPNode', 'type': 'object', 'id': 'tp_node', 'properties': { 'selector': { 'type': 'string', 'required': true }, 'attributes': { …
William
  • 1,517
  • 1
  • 12
  • 26
22
votes
4 answers

Is there a standard for specifying a version for json schema

One of our development partners have asked if there is a way we could specify an interface version within our JSON Schema definition. There isn't a "$version" key so is there a recognised "standard" that we ought to follow (I can't use $id as we are…
22
votes
1 answer

How to use a GraphQL schema for JSON Schema-like data validation?

We're looking into using GraphQL for version 2 of a headless CMS we're developing. In version 1 of this CMS, we used JSON Schema to validate each document against a schema before being saved in the database -- for example, if it's a blog article…
Ben Hoyt
  • 10,694
  • 5
  • 60
  • 84
21
votes
1 answer

JSON schema anyOf validation based on one of properties

I'm having difficulty figuring out how to validate an array of objects based on the value of one of the properties. So where I have a JSON object like: { "items": [ { "name": "foo", "otherProperty": "bar" …
Fo.
  • 3,752
  • 7
  • 28
  • 44
21
votes
2 answers

How to use definitions in JSON schema (draft-04)

The rest service response I am working with is similar to following example, I have only included 3 fields here but there are many more: { "results": [ { "type": "Person", "name": "Mr Bean", …
nishant
  • 955
  • 2
  • 11
  • 27
21
votes
5 answers

Use JSON.NET to generate JSON schema with extra attributes

I am using JSON.NET to generate JSON Schema from c# object class. But I was unable to add any other json schema attributes e.g. maxLength, pattern(regex to validate email), etc Below is my working code, I can only generate json schema with required…
Yoh
  • 211
  • 1
  • 2
  • 3
20
votes
5 answers

Is there a tool to generate a JSON schema from an XML schema through Java?

Is anyone aware of a tool or approach from which we can generate a JSON schema from XML schema or XML schema from JSON schema by Java?
Harish Raj
  • 1,565
  • 3
  • 17
  • 27