กลับไปยังภาพรวม API

json-validate

POST1 เครดิต

Parses a JSON string and returns either a pretty-printed version or a structured error pointing at the line and column of the failure. Useful for CI linting and form validation.

เอ็นด์พอยต์

POST https://x114.org/api/v1/json-validate

เนื้อหาคำขอ

ส่งเป็น JSON ในเนื้อหา POST

NameTypeRequiredDescription
jsonstringrequiredThe JSON text to validate.
mode"validate" | "format" | "minify"optionalWhat to do with the input. "validate" parses and reports; "format" pretty-prints with 2-space indent; "minify" strips whitespace. Defaults to "validate".

เนื้อหาการตอบสนอง

JSON ที่ส่งคืนเมื่อสำเร็จ (HTTP 200)

NameTypeRequiredDescription
okbooleanrequiredTrue on a well-formed response (parse error still surfaces).
modestringrequiredEchoes the mode that was applied.
validbooleanrequiredTrue when the JSON parses; false when a parse error is reported.
typestringoptionalTop-level JSON type ("object"|"array"|"string"|"number"|"boolean"|"null"). Only set in validate mode on success.
datastringoptionalFormatted or minified JSON string. Only set in format/minify mode on success.
sizenumberoptionalSize in characters of the input (validate) or output (format/minify).
errorstringoptionalHuman-readable error message (only set when valid is false).

ตัวอย่าง

curl -X POST https://x114.org/api/v1/json-validate \
  -H "Authorization: Bearer sk_..." \
  -H "Content-Type: application/json" \
  -d '{"json":"{\"a\":1}","mode":"format"}'
ลองในเบราว์เซอร์

เครื่องมือฟรีให้ผลลัพธ์เดียวกันโดยไม่ต้องเขียนโค้ดใดๆ

เปิดเครื่องมือ