I have an object in which the "key" of the property will be set dynamically ... What is the correct way to define this in a JSON schema?
This is what my object looks like
{ "column_definitions": [ { "Field_1": { "type": "Numeric", "isNullable": false } }, { "Field_2": { "type": "Boolean", "isNullable": true } } ], "row_values": [ ... ] }
The "key" in the "column_definitions" parameters will always be dynamic (it can be "Field_1" in the same way as "Field_24"
How to correctly define this in a JSON schema?
I donโt want to just say "type": "object" because I want to be able to define the static properties of "type" and "isNullable". In addition, I cannot use "oneOf" simply because I donโt know what it can be the "key" and there are no established values โโof potential.
This is what I still have:
{ "$schema": "http://json-schema.org/draft-04/schema", "title": "SomeSchema", "description": "SomeDescription", "type": "object", "properties": { "column_definitions": { "type": ["array", "null"], "items": { "$ref": "#/definitions/columnDef" }, "readOnly": true }, "row_values": { "type": ["array", "null"], "items": { "type": "object" }, "readOnly": true } }, "definitions": { "columnDef" : { "type": "object", "properties": { "THIS_IS_MY_DYNAMIC_PROPERTY": { "type": "object", "properties": { "type": { "type" : ["string", "null"], "enum": ["Text", "Boolean", "Numeric", "DateTime"], "readOnly": true }, "isNullable": { "type" : ["boolean", "null"], "readOnly": true } } } } } } }
json properties schema jsonschema
Gustavo
source share