Custom Properties in a JSON Schema

Is it possible to extend a JSON schema with custom properties?

The reason I ask is because I use a schema to render the form for the JSON described in the schema (each property described in the schema is used as a form element with a label and somehow).

It would be useful to be able to extend the schema with some properties that I mainly use to render the form, but this would be ignored when using the schema to validate the JSON object itself.

I could have two different views for the JSON object (one of them is a diagram, and one is an object similar to a diagram with custom properties that I only have to create the form, but it would be easier to maintain if I can combine both in one) .

Unfortunately, Google didn’t help much, and I don’t have much experience using JSON schemes, so I apologize if I missed something obvious.

Edit 1:
Example schematic fragment:

{ "title": "Example Schema", "type": "object", "properties": { "firstName": { "type": "string", "CUSTOM_PROPERTY": "CUSTOM_VALUE" } } }

Please note that the above is just a fragment and therefore does not have title, $schemaetc.

+4
source share
1 answer

(if valid JSON), the validator will most likely ignore your custom properties. But which validator are you going to use? Check it against this particular validator.

Here you have online validators for testing:

, JSON, . http://json-schema.org/latest/json-schema-core.html#rfc.section.6.4

+4

Source: https://habr.com/ru/post/1663116/


All Articles