Ho un oggetto in cui la "chiave" della proprietà sarà impostata dinamicamente ... qual è il modo giusto di definirlo in uno schema JSON?Schema JSON per proprietà dinamiche
Questo è ciò che il mio oggetto appare come
{
"column_definitions": [
{
"Field_1": {
"type": "Numeric",
"isNullable": false
}
},
{
"Field_2": {
"type": "Boolean",
"isNullable": true
}
}
],
"row_values": [ ... ]
}
La "chiave" delle "column_definitions" sarà sempre dinamica (può essere "Campo_1" tanto quanto può essere "Field_24"
Qual è il corretto definire questo in JSON Schema
non voglio dire solo "tipo":? "oggetto" perché voglio essere in grado di definire le proprietà statiche "tipo" e "IsNullable" anche , non posso usare "oneOf" semplicemente perché non so cosa La "chiave" può essere potenzialmente e non ci sono valori potenziali impostati.
Questo è quello che ho finora:
{
"$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 }
}
}
}
}
}
}
Sei riuscito a risolverlo? Sto affrontando la stessa situazione ora – mnvbrtn