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

Importing all definitions from an external JSON Schema

I've been experimenting with JSON Pointers to reference and reuse JSON schemas. Following the examples, I'm able to reference a specific property declared in another JSON schema and everything goes as expected, but I haven't found a way to extend a…
6
votes
3 answers

JSON Schema for Array of tuples

Thanks in advance. I am new to JSON & JSON schema. Tried to generate JSON schema for array of tuples. but it is not validating multiple records like a loop for all similar types of tuples. Below is json sample. { "Data": [ [ 100, "Test",…
NitinK
  • 103
  • 1
  • 7
6
votes
3 answers

How can I export a rails model to json schema?

I am looking to optimize how we build forms for some of our models and ideally I would like to build them from json-schema. Is there a gem or the like which would allow me to export a model definition to json-schema? Bonus: With validations.…
unomi
  • 2,642
  • 18
  • 19
6
votes
1 answer

JSON schema: how to allow empty string for property with numeric type?

In the property definition i need to allow numeric or empty string value, is this expression right for this purpose? "tprice":{"type":["number",{"enum":[""]}]} Library, that i use to validate data (Jsv4) generates error for empty string: Invalid…
vitus
  • 91
  • 1
  • 1
  • 4
6
votes
1 answer

tools to convert jsonschema into Django REST serializisers?

I've written a json-schema to validate the json that comes with the POST request to my API. No I need to deserialize this json. When I started builing the nested serializers structure I noticed that the process is very similar. So my question is:…
ganqqwerty
  • 1,894
  • 2
  • 23
  • 36
6
votes
1 answer

json schema for a map of similar objects

I wish to write a json schema to cover this (simplified) example { "errorMessage": "", "nbRunningQueries": 0, "isError": False, "result": { "foo": {"price":10.0, "country":"UK"}, "bar": {"price":100.2,…
Transact Charlie
  • 2,195
  • 17
  • 14
6
votes
2 answers

Jackson JsonSchemaGenerator - How to get Schema as String

I'm sure I'm just being dense here. I want to take an object schema, and turn it into a string representation. Like so, but this returns null: JsonSchemaGenerator generator = new JsonSchemaGenerator(MAPPER); JsonSchema jsonSchema =…
mtyson
  • 8,196
  • 16
  • 66
  • 106
6
votes
1 answer

protobuf IDL --> JSON schema

I want to auto-convert protobuf IDL (sans service specs) to JSON schema as part of a build process. Does there exist a tool I can use for this purpose and if so what is it?
user
  • 4,920
  • 3
  • 25
  • 38
6
votes
2 answers

Json schema property aliasing

The following JSON Schema describes a valid JSON for a lat/lon coordinate: { "title": "coordinates", "type": "object", "properties": { "longitude": { "type": "number", "minimum": -180, "maximum":180, …
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
6
votes
1 answer

JSON data validation under JSON-schema

I'm trying to validate some json data with ruby gem json-schema. I have the following schema: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "User", "description": "A User", "type": "object", "properties": { …
Eduardo Mello
  • 925
  • 3
  • 15
  • 32
6
votes
1 answer

Generate java classes from a JSON schema

I would like to generate JAVA classes from a given JSON Schema draft 4 version I evaluated couple of tools and jsonschema2pojo was found to be useful. But it supports json schema draft-3 version only(although json schema draft 4 is in their…
Saraswathi
  • 61
  • 1
  • 3
6
votes
4 answers

How do I verify if JSON data satisfy a JSON Schema specification?

I have JSON data in a file called B.json and another file with a JSON schema called BSchema.json. I'd like to know how to verify if the JSON data satisfy the JSON Schema specification, for example, in Ubuntu and Windows I can use the xmllint program…
Zignd
  • 6,896
  • 12
  • 40
  • 62
5
votes
4 answers

Some questions related to custom json schema

I'm noob to json. While defining the format of my RESTful API's result (viz JSON), I felt it would be easier to document it as my own JSON schema. While writing one I had few questions: In my result JSON, how do I specify the URI to teh schema it…
Kashyap
  • 15,354
  • 13
  • 64
  • 103
5
votes
1 answer

How to set up a custom AJV keyword?

I'm using ajv and want to add a custom validator inspecting a given object. This custom validator should either return true or fail with the correct error message. Based on (deprecated syntax) AJV custom keyword…
user17298649
5
votes
1 answer

How do I incorporate JSON schema into my OpenAPI file?

Say I have an OpenAPI swagger.yml file that looks like: openapi: '3.0.2' info: title: Simplest ever version: '1.0' servers: - url: https://api.server.test/v1 paths: /test: get: responses: '200': description: OK …
hendry
  • 9,725
  • 18
  • 81
  • 139