{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://redbook.fun/specification/1.0/schemas/value.schema.json",
  "oneOf": [
    {
      "type": "null"
    },
    {
      "type": "boolean"
    },
    {
      "$ref": "#/$defs/text"
    },
    {
      "type": "number",
      "allOf": [
        {
          "if": {
            "type": "integer"
          },
          "then": {
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        }
      ]
    },
    {
      "type": "array",
      "items": {
        "$ref": "#"
      }
    },
    {
      "$ref": "#/$defs/map"
    },
    {
      "type": "object",
      "properties": {
        "$rb": {
          "const": "integer"
        },
        "value": {
          "type": "string",
          "pattern": "^[+-]?[0-9]+(?![\\s\\S])"
        }
      },
      "required": [
        "$rb",
        "value"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "$rb": {
          "const": "decimal"
        },
        "value": {
          "type": "string",
          "pattern": "^[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?![\\s\\S])"
        }
      },
      "required": [
        "$rb",
        "value"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "$rb": {
          "const": "reference"
        },
        "id": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "$rb",
        "id"
      ],
      "additionalProperties": false
    }
  ],
  "$defs": {
    "text": {
      "type": "string",
      "not": {
        "pattern": "[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\ufffe\\uffff\\ud800-\\udfff]"
      }
    },
    "map": {
      "type": "object",
      "propertyNames": {
        "allOf": [
          {
            "type": "string",
            "not": {
              "pattern": "[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\ufffe\\uffff\\ud800-\\udfff]"
            }
          },
          {
            "not": {
              "const": "$rb"
            }
          }
        ]
      },
      "additionalProperties": {
        "$ref": "#"
      }
    }
  }
}
