{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/hayson/latest.json",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/j2inn/hayson/master/hayson-json-schema.json",
    "sourceSha256": "4d20d511ed73706cfa6440725260eb3966e875676d90117c7e3e8c32a5a55742",
    "fileMatch": [
      "*.hayson.json",
      "*.hayson.yaml",
      "*.hayson.yml"
    ],
    "parsers": [
      "json",
      "yaml"
    ]
  },
  "anyOf": [
    {
      "$ref": "#/$defs/hval"
    }
  ],
  "$defs": {
    "grid": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "grid"
          ]
        },
        "meta": {
          "$ref": "#/$defs/gridMeta"
        },
        "cols": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/gridColumn"
          }
        },
        "rows": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/dict"
          }
        }
      },
      "required": [
        "_kind",
        "meta"
      ],
      "additionalProperties": false
    },
    "gridMeta": {
      "allOf": [
        {
          "$ref": "#/$defs/dict"
        }
      ],
      "type": "object",
      "required": [
        "ver"
      ],
      "properties": {
        "ver": {
          "type": "string",
          "enum": [
            "3.0"
          ]
        }
      }
    },
    "gridColumn": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "meta": {
          "$ref": "#/$defs/dict"
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "dict": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "dict"
          ]
        }
      },
      "additionalProperties": false,
      "patternProperties": {
        "^[a-z][0-9a-zA-Z_]*": {
          "$ref": "#/$defs/hval"
        }
      }
    },
    "list": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/hval"
      }
    },
    "hval": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "boolean"
        },
        {
          "$ref": "#/$defs/marker"
        },
        {
          "$ref": "#/$defs/remove"
        },
        {
          "$ref": "#/$defs/na"
        },
        {
          "$ref": "#/$defs/number"
        },
        {
          "$ref": "#/$defs/symbol"
        },
        {
          "$ref": "#/$defs/ref"
        },
        {
          "$ref": "#/$defs/uri"
        },
        {
          "$ref": "#/$defs/date"
        },
        {
          "$ref": "#/$defs/time"
        },
        {
          "$ref": "#/$defs/dateTime"
        },
        {
          "$ref": "#/$defs/dict"
        },
        {
          "$ref": "#/$defs/list"
        },
        {
          "$ref": "#/$defs/grid"
        },
        {
          "$ref": "#/$defs/coord"
        },
        {
          "$ref": "#/$defs/xstr"
        }
      ]
    },
    "marker": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "marker"
          ]
        }
      },
      "required": [
        "_kind"
      ],
      "additionalProperties": false
    },
    "remove": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "remove"
          ]
        }
      },
      "required": [
        "_kind"
      ],
      "additionalProperties": false
    },
    "na": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "na"
          ]
        }
      },
      "required": [
        "_kind"
      ],
      "additionalProperties": false
    },
    "number": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "$ref": "#/$defs/numberObj"
        },
        {
          "$ref": "#/$defs/numberSpecial"
        }
      ]
    },
    "numberObj": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "number"
          ]
        },
        "val": {
          "type": "number"
        },
        "unit": {
          "type": "string",
          "pattern": "^([a-zA-Z%_/$]|[\\x80-\\xFFFF])+$"
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "numberSpecial": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "number"
          ]
        },
        "val": {
          "type": "string",
          "enum": [
            "INF",
            "-INF",
            "NaN"
          ]
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "uri": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "uri"
          ]
        },
        "val": {
          "type": "string"
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "ref": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "ref"
          ]
        },
        "val": {
          "type": "string",
          "pattern": "^[0-9a-zA-Z_:\\-.~]+$"
        },
        "dis": {
          "type": "string"
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "symbol": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "symbol"
          ]
        },
        "val": {
          "type": "string",
          "pattern": "^[0-9a-zA-Z_:\\-.~]+$"
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "date": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "date"
          ]
        },
        "val": {
          "type": "string",
          "format": "date"
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "time": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "time"
          ]
        },
        "val": {
          "type": "string",
          "pattern": "^(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]+)?$"
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "dateTime": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "dateTime"
          ]
        },
        "val": {
          "type": "string",
          "pattern": "^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]+)?(Z|[-+](2[0-3]|[01][0-9]):[0-5][0-9])?$"
        },
        "tz": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "_kind",
        "val"
      ],
      "additionalProperties": false
    },
    "coord": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "coord"
          ]
        },
        "lat": {
          "type": "number"
        },
        "lng": {
          "type": "number"
        }
      },
      "required": [
        "_kind",
        "lat",
        "lng"
      ],
      "additionalProperties": false
    },
    "xstr": {
      "type": "object",
      "properties": {
        "_kind": {
          "type": "string",
          "enum": [
            "xstr"
          ]
        },
        "type": {
          "type": "string",
          "pattern": "^[A-Z][a-zA-Z0-9_]*$"
        },
        "val": {
          "type": "string"
        }
      },
      "required": [
        "_kind",
        "type",
        "val"
      ],
      "additionalProperties": false
    }
  }
}
