相关疑难解决方法(0)

动态属性的JSON模式

我有一个对象,其中属性的"键"将动态设置...在JSON模式中定义它的正确方法是什么?

这就是我的对象的样子

{
  "column_definitions": [    
    {
     "Field_1": {
       "type": "Numeric",
       "isNullable": false
      }
    },
    {
     "Field_2": {
       "type": "Boolean",
       "isNullable": true
      }
    }
 ],
 "row_values": [ ... ]
}
Run Code Online (Sandbox Code Playgroud)

"column_definitions"的"关键字"将始终是动态的(它可以是"Field_1",就像它可以是"Field_24"一样多)

在JSON Schema中定义它的适当方法是什么?

我不想只说"类型":"对象",因为我希望能够定义静态属性"类型"和"isNullable"另外,我不能使用"oneOf"只是因为我不知道什么是"关键"可以可能是并且没有设定的潜在价值.

这是我到目前为止:

{
  "$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": …
Run Code Online (Sandbox Code Playgroud)

schema json properties jsonschema

8
推荐指数
1
解决办法
5952
查看次数

标签 统计

json ×1

jsonschema ×1

properties ×1

schema ×1