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

订单 JSON Schema

高级 JSON Schema

综合订单 Schema,包含状态枚举、商品数组和总计对象。 一个真实、可直接使用的示例,你可以复制、调整,或用来测试自己的代码。

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Order",
  "type": "object",
  "properties": {
    "orderId": { "type": "string", "pattern": "^ORD-[0-9]{5}$" },
    "status": {
      "type": "string",
      "enum": ["pending", "confirmed", "shipped", "delivered", "cancelled"]
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "productId": { "type": "string" },
          "quantity": { "type": "integer", "minimum": 1 },
          "unitPrice": { "type": "number", "minimum": 0 }
        },
        "required": ["productId", "quantity", "unitPrice"]
      }
    },
    "totals": {
      "type": "object",
      "properties": {
        "subtotal": { "type": "number" },
        "tax": { "type": "number" },
        "shipping": { "type": "number" },
        "grandTotal": { "type": "number" }
      }
    }
  },
  "required": ["orderId", "status", "items"]
}
JSON 示例