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

json schema with one mandatory property and at least one another not typed checked

I have this object in json which I would like to validate with a json schema "reference": { "lookup" : "opportunity", "shortreference": 93671, "guid": "4bb30c46-20ec-e511-9408-005056862bfb" } lookup property is mandatory, and then I…
camous
  • 998
  • 11
  • 27
7
votes
2 answers

JSON schema enum vs pattern for single value

I have an sample json: { "type": "persons", "id": 2, "attributes": { "first": "something", "second": "something else" } } And I have to make a schema for it (using JSON API specs and JSON schema docs): { …
3Gee
  • 1,094
  • 2
  • 14
  • 23
7
votes
1 answer

Spring Data Rest - Custom Json Schema / Alps?

My need is to give information about data constraints or default values to the client app that will use the API. The schema or the ALPS generated by Spring Data Rest seems to be a good place to put this information. But the part about documenting…
JR Utily
  • 1,792
  • 1
  • 23
  • 38
7
votes
2 answers

jsonschema and date type

I'm just getting started with jsonschema and an example under "Using jsonschema2pojo within your Java project (embedded)" in https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started having in mind data types of jsonschema listed here…
hhg
  • 649
  • 1
  • 11
  • 20
7
votes
1 answer

JSON Schema: verifying object's values, without keys

Not to confuse anybody, I'll start with validating arrays... Regarding arrays, JSON Schema can check whether elements of an (((...)sub)sub)array conform to a structure: "type": "array", "items": { ... } When validating objects, I know I can pass…
ducin
  • 25,621
  • 41
  • 157
  • 256
7
votes
3 answers

JSON schema validation for null when "type"="string"

I wanted to prevent a json filed from allowing null as a valid value for it. Tried using the keyword not, but no luck. Want the below json to be validated as false, as the field stats as value as null. { "stats": "null" } please find my schema…
Manu
  • 1,379
  • 6
  • 24
  • 53
7
votes
2 answers

Is it allowed to combine $ref with other keywords in JSON Schema?

I'm learning JSON Schema for one of the open-source projects. Have a question concerning combining an already defined schema with some additional keywords. Assume I've defined some schema which is available via the reference, for example…
lexicore
  • 42,748
  • 17
  • 132
  • 221
7
votes
2 answers

define a schema with JSON-Schema and use Mongoose?

Hullo, I have a crux to bear with Mongoose. Is there a way of using JSON-Shema with Mongoose Schemas? Say I want to define my API data schema using a standard like JSON-Schema, because it's nice. It seems like I need to define it again when I want…
sebbulon
  • 613
  • 7
  • 21
7
votes
2 answers

Is there json schema of json schema?

Is there JSON Schema of JSON Schema? In my app user can upload his JSON schema and I would like to validate it if it's a valid JSON Schema.
user606521
  • 14,486
  • 30
  • 113
  • 204
7
votes
1 answer

Automatically generate JavaScript from JSON Schema

After hourlong searching I have found no solution about my problem and now I hope someome could be able to help me here. So basically what I am looking for is a way to generate a JavaScript file (*.js) from a JSON (Schema) file automatically using…
Stefan C.
  • 101
  • 1
  • 6
7
votes
2 answers

Mutually exclusive property groups

Suppose I have an object with four possible properties: a, b, c, d. a and b can only appear together (i.e., a appears if and only if b appears). If a and b appear, c cannot appear (that is, a/b and c are mutually exclusive). If a and b do not…
Ray
  • 1,769
  • 1
  • 17
  • 22
7
votes
0 answers

How to check if objects in array are unique by certain property

Let's suppose that I have this schema: "array": { "type": "array", "items": { "type": "object", "properties": {"id": {"type": "integer"}, "value": {"type": "number"}} }, "uniqueItems": true } But I need to ensure that there are no…
Andrey Kon
  • 747
  • 2
  • 6
  • 16
7
votes
1 answer

@JsonPropertyOrder not working with jackson-module-jsonSchema

I'm using the latest branch for Jackson module - jackson-module-jsonSchema i.e. 2.4.4-Snapshot. I'm trying to use the @JsonPropertyOrder annotation to maintain the order of the POJO attributes, but it seems to be not respecting the annotation. My…
Piyush Jajoo
  • 1,095
  • 2
  • 18
  • 27
7
votes
2 answers

Writing JSON schema to detect objects with duplicate names

According to the following post; Does JSON syntax allow duplicate keys in an object? Keys with the same name in JSON are valid, but most parsers will override the value with the last value it finds. Is there anyway in a json schema to detect…
Mike Mellor
  • 1,316
  • 17
  • 22
7
votes
1 answer

How to get a json schema from another file?

I want to know how to get a json schema from an other file. Suppose I have two files, placed in the same directory: File 1: person.json { "id":"#person", "name": {"type":"string"}, "age": {"type":"number"}, "address": { …
joaorodr84
  • 1,251
  • 2
  • 14
  • 33