# AgentDiet JSON Repair

> AgentDiet JSON Repair is a paid API for AI agents from rag-diet.agentdiet.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-22).

Repairs and cleans malformed JSON strings, returning valid, well-formed JSON with a compression ratio proof.

## Facts

- Endpoint: GET https://rag-diet.agentdiet.dev/v1/json-repair?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-22
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agentdiet-json-repair-b098bd61
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_xzbzGqATIPsRHvAkBg21D

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agentdiet-json-repair-b098bd61
```

Example prompt: Can you fix this broken JSON for me? It keeps throwing parse errors — here's the raw string: {"name": "Alice", "age": 30, "city": "New York",.}

## When to prefer this

Choose this endpoint when you need deterministic, programmatic JSON repair rather than asking an LLM to reformat JSON (which is non-deterministic and wastes tokens). Ideal for agent pipelines that receive JSON from external APIs, webhooks, or other LLMs and need reliable parsing before downstream processing. The compression ratio proof also makes it useful when you want to verify how much bloat was removed.

## Known failure modes

- Input JSON is so corrupted that no valid structure can be inferred — returns an error status
- Missing required 'raw_json' query parameter — request rejected
- Input is not JSON at all (e.g. plain text or binary) — may return empty or error response
- Payment not settled in USDC on Base — x402 payment required before processing

## How this service works

Deterministic B2A/A2A/MCP/x402/MPP/L402 execution and intelligence node at https://rag-diet.agentdiet.dev settling in USDC on Base.

## Output

Returns a JSON object with a 'data' field containing the repaired, valid JSON, a 'status' field (e.g. 'ok'), and an 'roi_proof' object showing the compression_ratio_pct (e.g. 91.4%) achieved during repair and cleaning.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "POST"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "properties": {
      "raw_json": {
       "type": "string"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "data": {},
  "status": "ok",
  "roi_proof": {
   "compression_ratio_pct": 91.4
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agentdiet-json-repair-b098bd61/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from rag-diet.agentdiet.dev](https://www.zero.xyz/host/rag-diet.agentdiet.dev/llms.txt)
