校验结构化数据语法

POST/format/validate
公开访问curl

合法文档返回 valid: true。XML 支持无 DTD 的文档,CSV 需要非空且唯一的表头。 访问类别:匿名 API,可携带 Token 使用独立额度

请求参数

_formatquery
响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
string · 可选:json、text
_colorquery
控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
string · 可选:0、false、off、no

请求体

application/json
text必填
string · 最长:65536 字符
format必填
string · 可选:json、yaml、toml、csv、xml

响应

application/json

{
  "type": "object",
  "properties": {
    "valid": {
      "type": "boolean",
      "enum": [
        true
      ]
    }
  },
  "required": [
    "valid"
  ]
}

响应示例

成功响应

curl -sS --json '{"format":"toml","text":"count = 2"}' https://oit.sh/format/validate
HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "valid": true
}

错误示例

curl -sS --json '{}' https://oit.sh/format/validate
HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "error": {
    "code": "INVALID_INPUT",
    "message": "参数无效",
    "issues": [
      {
        "location": "body",
        "field": "text",
        "code": "invalid_type",
        "message": "需要 字符串 类型"
      },
      {
        "location": "body",
        "field": "format",
        "code": "invalid_value",
        "message": "允许值:json、yaml、toml、csv、xml"
      }
    ]
  }
}

curl 访问示例

curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。

命令与输出

curl -sS --json '{"format":"toml","text":"count = 2"}' 'https://oit.sh/format/validate?_color=0&_format=text'
HTTP 200
content-type: text/plain; charset=utf-8
content-encoding: gzip
cache-control: no-store

valid: true

在线调试

必填
必填
Ctrl / ⌘ + Enter
curl -X POST 'https://oit.sh/format/validate' \
  -H 'Content-Type: application/json' \
  --data-raw '{"text":"count = 2","format":"toml"}'

响应

等待请求

等待发送请求