跳转到主要内容
CuteJSON
↑↓ 导航 Enter 选择 Esc 关闭

用户 JSON Schema

中级 JSON Schema

用于验证用户对象的 JSON Schema,包含必填字段、模式和枚举。 一个真实、可直接使用的示例,你可以复制、调整,或用来测试自己的代码。

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/user.schema.json",
  "title": "User",
  "description": "A user account in the system.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^usr_[a-z0-9]{6}$",
      "description": "Unique user identifier"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "age": {
      "type": "integer",
      "minimum": 0,
      "maximum": 150
    },
    "role": {
      "type": "string",
      "enum": ["admin", "editor", "viewer"]
    }
  },
  "required": ["id", "name", "email"],
  "additionalProperties": false
}
JSON 示例