{
"count": 1,
"items": [
{
"valid": false,
"repaired": true,
"data": {
"name": "Ada",
"tags": [
"math",
"code"
],
"active": true,
"bio": "First programmer, see http://x.com//ada",
"born": 1815
},
"json": "{\"name\":\"Ada\",\"tags\":[\"math\",\"code\"],\"active\":true,\"bio\":\"First programmer, see http://x.com//ada\",\"born\":1815}",
"fixes": [
{
"type": "code_fence",
"at": 18,
"detail": "markdown code fence removed"
},
{
"type": "prose_removed",
"at": 0,
"detail": "17 characters of text around the JSON ignored"
},
{
"type": "single_quotes",
"at": 27,
"detail": "single-quoted string -> double quotes"
},
{
"type": "single_quotes",
"at": 35,
"detail": "single-quoted string -> double quotes"
},
{
"type": "unquoted_key",
"at": 42,
"detail": "key quoted"
},
{
"type": "trailing_comma",
"at": 63,
"detail": "trailing comma removed"
},
{
"type": "unquoted_key",
"at": 67,
"detail": "key quoted"
},
{
"type": "python_literal",
"at": 75,
"detail": "True -> true"
},
{
"type": "comment",
"at": 81,
"detail": "// comment removed"
},
{
"type": "truncated_closed",
"at": 154,
"detail": "input ended early; closed open object"
},
{
"type": "coerced",
"at": null,
"detail": "/born: \"1815\" -> integer 1815"
}
],
"fixCount": 11,
"truncated": true,
"schemaValid": true,
"schemaErrors": [],
"inputChars": 154,
"ms": 108.97
}
]
}
curl --location --request GET 'https://zylalabs.com/api/15804/json+repair+api/43297/json+repair+api?json=Sure! Here it is:
```json
{'name': 'Ada', tags: ["math", "code",], active: True, // note
"bio": "First programmer, see http://x.com//ada", "born": "1815"&coerce=true&extract=first' --header 'Authorization: Bearer YOUR_API_KEY'
注册后,每个开发者都会被分配一个个人 API 访问密钥,这是一个唯一的字母和数字组合,用于访问我们的 API 端点。要使用 JSON 修复 API 进行身份验证,只需在 Authorization 标头中包含您的 bearer token。
| 标头 | 描述 |
|---|---|
授权
|
必需
应为 Bearer access_key. 订阅后,请查看上方的"您的 API 访问密钥"。
|
一次调用修复格式错误的 LLM JSON:代码围栏、尾随逗号、引号、注释、截断的输出。可选的 JSON Schema 校验与强制类型转换。约 5 毫秒
一次调用修复格式错误的 LLM JSON:代码围栏、尾随逗号、引号、注释、截断的输出。可选 JSON Schema 校验和强制转换。约 5 毫秒
每个请求最多返回 100 条结果,具体取决于端点。 .
每个请求都会从公共来源收集实时数据。相同的请求可能会从缓存中提供,缓存有效期最长为 6 小时。
列表参数接受多个以逗号分隔的值,例如:london,paris. .
此端点接受以下查询参数,均为可选:json、coerce、extract。Json:格式有误的 JSON 文本(或包含周围说明文字的完整模型回答),最多 1,000,000 个字符 coerce:使用架构时,将明显的类型不匹配转换为正确类型(“12” -> 12,“true” -> true,value -> [value]),并将每项转换列为修复项 extract:当文本中包含多个 JSON 块时,要提取哪一个:first、largest 或 all
`valid` 表示提交的文本在修复前是否为有效的 JSON。当 API 成功修复输入时,响应可以是 `valid: false` 和 `repaired: true`天天爱彩票
每个条目描述一项修复,包含 `type`、字符位置(`at`)和说明性 `detail`。例如,`code_fence` 表示移除了 Markdown 代码围栏,而 `prose_removed` 描述了 JSON 周围被忽略的文本】【。
`data` 包含解析后的结构化 JSON 数据,而 `json` 包含其序列化后的 JSON 文本。将 `data` 用于以对象形式处理结果,将 `json` 用于需要 JSON 字符串的场景。
它可以忽略 JSON 周围的闲聊文本,并将此更改报告为 `prose_removed` 修复。如果输入包含多个 JSON 块,`extract` 参数将控制选择第一个、最大的还是全部
API 可以通过干净地闭合未完成的字符串来修复部分截断的输出,然后返回生成的数据,并在 `fixes` 中描述修复内容。请检查返回的数据,确认其符合您的使用场景
该 API 支持可选的 JSON Schema 验证和类型强制转换。启用 Schema 类型强制转换后,它可以转换明显的类型不匹配,例如将 `"12"` 转换为 `12`,并将每次转换报告为一项修正
它可以处理常见的大语言模型输出问题,包括多余或缺失的逗号、单引号或智能引号、未加引号的键、注释、`True` 和 `None` 等 Python 值、`NaN` 以及字符串中的原始换行符