Conservative JSON Repair Batch
Repair 1–5 supplied JSON-like texts under an explicit conservative grammar: comments, trailing commas, ASCII unquoted keys, single quotes, Python True/False/None, leading BOM and one enclosing JSON fence. Return unchanged originals, repaired text, parsed values, exact edit traces and independent item rejections. No missing values, delimiters or truncated data are inferred.
document-assurance · Operation ID: json-repair
Choose this operation when
- Repair known syntactic defects in caller-supplied JSON-like text
- Preserve original text and inspect every change before trusting a structured artifact
Outside this profile
- Arbitrary JSON5 or Python parsing, schema validation, semantic correction or guaranteed repair
- Completing truncated values, guessing missing delimiters or selecting duplicate keys
- Large documents, arbitrary-precision numbers or a cheapest single-call guarantee
Exact release references
Static JSON contract · Markdown reference · Fixed example response
Complete input schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"profile": {
"type": "string",
"const": "conservative-json-repair-v1"
},
"items": {
"minItems": 1,
"maxItems": 5,
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"pattern": "^[A-Za-z0-9_-]+$"
},
"text": {
"type": "string",
"maxLength": 16000
}
},
"required": [
"id",
"text"
],
"additionalProperties": false
}
}
},
"required": [
"profile",
"items"
],
"additionalProperties": false
}
Complete output-envelope schema
{
"type": "object",
"required": [
"operation",
"version",
"result",
"provenance"
],
"properties": {
"operation": {
"const": "json-repair",
"type": "string"
},
"version": {
"const": "0.29.0",
"type": "string"
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"profile": {
"type": "string",
"const": "conservative-json-repair-v1"
},
"offsetUnit": {
"type": "string",
"const": "utf16-code-units"
},
"itemCount": {
"type": "integer",
"minimum": 1,
"maximum": 5
},
"successCount": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"rejectedCount": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"results": {
"minItems": 1,
"maxItems": 5,
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"pattern": "^[A-Za-z0-9_-]+$"
},
"originalText": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"repaired",
"unchanged"
]
},
"originalSha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"originalWasValidJson": {
"type": "boolean"
},
"repairedText": {
"type": "string"
},
"repairedSha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"value": {
"$ref": "#/properties/result/$defs/__schema0"
},
"edits": {
"maxItems": 200,
"type": "array",
"items": {
"type": "object",
"properties": {
"kind": {
"type": "string",
"enum": [
"remove-bom",
"remove-fence",
"replace-comment",
"remove-trailing-comma",
"quote-key",
"convert-single-quoted-string",
"convert-python-literal"
]
},
"start": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"end": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"before": {
"type": "string"
},
"after": {
"type": "string"
}
},
"required": [
"kind",
"start",
"end",
"before",
"after"
],
"additionalProperties": false
}
}
},
"required": [
"id",
"originalText",
"status",
"originalSha256",
"originalWasValidJson",
"repairedText",
"repairedSha256",
"value",
"edits"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 80,
"pattern": "^[A-Za-z0-9_-]+$"
},
"originalText": {
"type": "string"
},
"status": {
"type": "string",
"const": "rejected"
},
"originalSha256": {
"anyOf": [
{
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
{
"type": "null"
}
]
},
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"offset": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"code",
"message",
"offset"
],
"additionalProperties": false
}
},
"required": [
"id",
"originalText",
"status",
"originalSha256",
"error"
],
"additionalProperties": false
}
]
}
}
},
"required": [
"profile",
"offsetUnit",
"itemCount",
"successCount",
"rejectedCount",
"results"
],
"additionalProperties": false,
"$defs": {
"__schema0": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"type": "array",
"items": {
"$ref": "#/properties/result/$defs/__schema0"
}
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/properties/result/$defs/__schema0"
}
}
]
}
}
},
"provenance": {
"type": "object",
"required": [
"inputSha256",
"outputSha256",
"deterministic",
"externalRequests"
],
"properties": {
"inputSha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"outputSha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"deterministic": {
"const": true
},
"externalRequests": {
"const": 0
}
}
}
},
"additionalProperties": false
}
Fixed example
One accepted fixed example, not a custom-input trial. No operation runs when this static page is requested.
Example input
{
"profile": "conservative-json-repair-v1",
"items": [
{
"id": "paid-fixture",
"text": "{foo: 'bar', broken: true,}"
},
{
"id": "already-valid",
"text": "{\"items\":[1,2],\"ok\":true}"
},
{
"id": "truncated",
"text": "{\"name\":\"unfinished"
}
]
}
Example response
{
"operation": "json-repair",
"version": "0.29.0",
"result": {
"profile": "conservative-json-repair-v1",
"offsetUnit": "utf16-code-units",
"itemCount": 3,
"successCount": 2,
"rejectedCount": 1,
"results": [
{
"id": "paid-fixture",
"originalText": "{foo: 'bar', broken: true,}",
"status": "repaired",
"originalSha256": "180949792a87351e726ae3e5ea90bfa3ecf362028e987b6edce90abe359c0b2f",
"originalWasValidJson": false,
"repairedText": "{\"foo\": \"bar\", \"broken\": true}",
"repairedSha256": "a5640e8bcad859bf34dc8849af8f22a455c7dbd86f81a83287666b3dc0bb6eeb",
"value": {
"foo": "bar",
"broken": true
},
"edits": [
{
"kind": "quote-key",
"start": 1,
"end": 4,
"before": "foo",
"after": "\"foo\""
},
{
"kind": "convert-single-quoted-string",
"start": 6,
"end": 11,
"before": "'bar'",
"after": "\"bar\""
},
{
"kind": "quote-key",
"start": 13,
"end": 19,
"before": "broken",
"after": "\"broken\""
},
{
"kind": "remove-trailing-comma",
"start": 25,
"end": 26,
"before": ",",
"after": ""
}
]
},
{
"id": "already-valid",
"originalText": "{\"items\":[1,2],\"ok\":true}",
"status": "unchanged",
"originalSha256": "067816002380371fc6726553d6797b9cddfb32289bc801f9a82612f09f74e5d4",
"originalWasValidJson": true,
"repairedText": "{\"items\":[1,2],\"ok\":true}",
"repairedSha256": "067816002380371fc6726553d6797b9cddfb32289bc801f9a82612f09f74e5d4",
"value": {
"items": [
1,
2
],
"ok": true
},
"edits": []
},
{
"id": "truncated",
"originalText": "{\"name\":\"unfinished",
"status": "rejected",
"originalSha256": "24f03ddd7eff759bda2f2f10cae68b37cc828cf219b149b3011577819c32b8f3",
"error": {
"code": "TRUNCATED_STRING",
"message": "Missing string closing quote; no value is inferred",
"offset": 8
}
}
]
},
"provenance": {
"inputSha256": "a2c462b8c4f3bb0e6a6b0c6f4d34ad90507da1a4e1b48ac23a5d571ef2802b46",
"outputSha256": "6aa3bc1bf9fbc05627e4cf7534f8e8bf280ca6614eb13213262cf2e6479987dc",
"deterministic": true,
"externalRequests": 0
}
}
Bounds and precision
JavaScript IEEE-754 numbers; use strings for large integer IDs/exact decimals where the schema accepts strings. No lossless numeric parsing.
{
"global": {
"requestBytes": 131072,
"responseBytes": 524288,
"jsonDepth": 32,
"jsonNodes": 20000,
"requestsPerMinute": 60,
"paidAttemptsPerMinute": 20,
"idempotencyHours": 24
},
"operation": {
"items": 5,
"textCodeUnitsPerItem": 16000,
"inputBytes": 100000,
"outputBytes": 400000,
"nodesPerItem": 4000,
"depth": 20,
"editsPerItem": 200,
"numberTokenCodeUnits": 256,
"profile": "conservative-json-repair-v1",
"offsetUnit": "utf16-code-units",
"networkAccess": "none",
"schemaValidation": "not-performed"
}
}
Complete schemas, descriptions and cross-field validation may impose additional limits.
Proposed price and protocol definitions
{
"unit": "one successful operation call",
"proposedNominalUsd": "0.003",
"sixDecimalTokenBaseUnits": "3000",
"subscription": false,
"includesPayerWalletOrNetworkFees": false,
"liveQuoteVerified": false,
"condition": "Actual SDK challenge is authoritative only within the caller's explicit authorization; configured six-decimal token peg is an operator assertion, not a conversion guarantee."
}
Protocol definitions: x402, mpp. MPP uses Tempo charge. Paid MCP execution is unsupported. All runtime readiness is not evaluated in this build.
API path templates, not endpoints on this documentation host
{
"x402": "/v1/x402/json-repair",
"mpp": "/v1/mpp/json-repair"
}
Required headers
{
"Content-Type": "application/json",
"Idempotency-Key": "random 16–128 character operation identifier"
}
Actual SDK challenge amount, asset, network, recipient and wallet costs must pass independent authorization. Preserve identical key, body, protocol and credential on retries; on PAYMENT_UNCERTAIN stop and reconcile.
Execution profile and provider conditions
{
"deterministic": true,
"externalRequests": 0,
"maxExternalRequests": 0,
"resultSnapshotPersisted": false,
"fixedExampleIsIllustrativeSnapshot": false,
"requiresPayment": true,
"supportsMcpExecution": false
}
Deterministic supplied-input operation with no external requests or stored request/result bodies. Payment infrastructure retains payment metadata and hashes.
Failure handling
- HTTP 400: Malformed JSON, missing/invalid idempotency key, or payment identifier mismatch Correct the request before payment
- HTTP 402: Payment challenge or rejected payment Use official protocol SDK; inspect payment outcome before another payment
- HTTP 409: Idempotency conflict, duplicate proof, or PAYMENT_UNCERTAIN Keep original key, body, and proof; reconcile uncertainty with operator; never blindly repay
- HTTP 413: Input or generated output too large Reduce input; no payment attempted for validation failure
- HTTP 415: Unsupported media type or compression Send uncompressed application/json
- HTTP 422: Schema or service-specific semantic validation failure Correct input using returned error code; no payment attempted
- HTTP 429: Request/payment-attempt rate exceeded Wait for rate limit window; preserve existing payment identity
- HTTP 503: Payment configuration/provider/state unavailable, or live DNS preparation failed before settlement Check readiness; DNS preparation failures may retry the identical key/body/credential only; uncertainty requires reconciliation
Declared requirements
Before any paid call, refresh the live operation contract and POST the complete bounded budgeted plan to the separate API's /preflight. Unknown requirements block selection; compatible preflight is not permission to spend.