{"uid":"cap_CyaE867puetPqmW-3HWYC","slug":"patch-guard-json-repair-canonicalization-1174d962","name":"Patch Guard JSON Repair & Canonicalization","description":"Four x402-paid agent utilities: safe JSON Patch evaluation, multi-source crypto price consensus, normalized Polymarket movers, and deterministic JSON repair/canonicalization.","url":"https://patch-guard-api.me-e51.workers.dev/v1/json-repair","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"text":{"type":"string","maxLength":49152,"minLength":1,"description":"Valid or repairable JSON text, up to 48 KiB UTF-8."}}},"responseSchema":{"type":"json","example":{"bytes":{"input":28,"repaired":28,"canonical":28},"repairedJson":"{\"name\":\"Ada\",\"active\":true}","wasValidJson":false,"canonicalJson":"{\"active\":true,\"name\":\"Ada\"}","repairApplied":true,"canonicalSha256":"sha256:..."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_ksKEQj0g1zsLE2a_uxtOh","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Accepts malformed or valid JSON text and returns repaired JSON, canonicalized (sorted-key) JSON, and a SHA-256 fingerprint of the canonical form.","exampleAgentPrompt":"Can you repair and canonicalize this JSON for me? It came from an LLM and might be malformed: '{\"name\":\"Ada\",\"active\":true,\"score\":}'  — I need the fixed version with keys sorted alphabetically and a SHA-256 fingerprint of the canonical form.","exampleUseCases":[{"title":"LLM output sanitization pipeline","prompt":"This JSON came back from an AI model and it's broken — missing a closing bracket and has a trailing comma. Can you repair it, sort all the keys, and give me a SHA-256 of the canonical version so I can deduplicate it? Here it is: '{\"user\":\"bob\",\"roles\":[\"admin\",\"editor\",}'"},{"title":"Deterministic cache key generation","prompt":"I need to compare two JSON payloads that represent the same data but have keys in different orders. Can you canonicalize both of them and give me their SHA-256 hashes so I can tell if they're actually identical?"},{"title":"Pre-ingestion JSON validation and repair","prompt":"Before I store this config blob in my database, can you check if it's valid JSON, fix it if not, and return the repaired version along with the canonical sorted-key form? The text is: '{name: \"config\", version: 2, enabled: true}'"}],"resultDescription":"Returns an object containing: the repaired JSON string (repairApplied flag indicates whether changes were made), a canonicalized JSON string with keys sorted deterministically, a SHA-256 hash of the canonical form for fingerprinting, whether the input was already valid JSON, and byte counts for the input, repaired, and canonical forms.","failureModes":["Input JSON is so severely malformed it cannot be repaired — returns an error or best-effort partial result","Input exceeds 48 KiB limit — returns a validation error","Empty string input — rejected by minLength:1 constraint","Non-string input body — schema validation error","Payment not included or insufficient — 402 Payment Required response"],"whenToPreferThis":"Choose this endpoint when you need deterministic JSON normalization, deduplication via stable hashing, or repair of LLM-generated or user-supplied malformed JSON. It is purpose-built for agent pipelines that need to canonicalize JSON for cache keys, fingerprint documents, or sanitize untrusted JSON input before parsing. Prefer it over generic JSON validators when you need both repair AND canonical key ordering in a single atomic call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T06:32:09.646Z","isFirstParty":false}