# AgentDiet JSON Fix - Malformed JSON Repair API

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

Accepts raw malformed or broken JSON as a query parameter and returns a cleaned, valid JSON object with compression metadata.

## Facts

- Endpoint: GET https://mcp-gateway.agentdiet.dev/v1/json-fix?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-fix-malformed-json-repair-api-dc84c984
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Cxw4UtF-EDq7LCUbCSFdK

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-fix-malformed-json-repair-api-dc84c984
```

Example prompt: I have this broken JSON string that won't parse — can you fix it and return valid JSON? Here it is: {name: 'Alice', age: 30, hobbies: ['reading', 'coding'} — it's missing a closing bracket.

## When to prefer this

Use this endpoint when you have a malformed, broken, or syntactically invalid JSON string that needs to be repaired and returned as a valid parseable JSON object, particularly in automated agent pipelines where LLM outputs or third-party API responses frequently contain JSON syntax errors. Prefer this over manual parsing logic when you need a quick, pay-per-use fix with no infrastructure overhead, paid in USDC micro-transactions via x402.

## Known failure modes

- Input is so malformed it cannot be heuristically repaired — returns error or empty data object
- Missing required 'input' field or 'method' field causes schema validation failure
- Extremely large JSON strings may hit size limits or timeout
- Non-JSON text passed as raw_json may return unexpected results or error

## How this service works

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

## Output

A JSON response containing a 'data' field with the corrected/cleaned JSON object, a 'status' field indicating success (e.g. 'ok'), and a 'roi_proof' object showing the compression_ratio_pct achieved during repair (e.g. 91.4%).

## 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-fix-malformed-json-repair-api-dc84c984/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from mcp-gateway.agentdiet.dev](https://www.zero.xyz/host/mcp-gateway.agentdiet.dev/llms.txt)
