extract_correct_parse_json
JSON repair: extracts structured JSON from messy text or LLM output, optionally validating and auto-correcting it against a JSON Schema
- Prix
- $0.006 USDC · par appel
- Service
- Extract correct
- Catégorie
- Validation de données
- Endpoint
POST /v1/extract-correct/parse_json
Reads free-form or messy text -- already-valid JSON, JSON wrapped in prose or a markdown code fence, or malformed JSON (trailing commas, single-quoted strings, unquoted keys, a truncated array/object) -- and returns the extracted structured JSON value. 100% local, deterministic extraction and repair (a classical JSON-repair algorithm plus a hand-written balanced-bracket scanner) -- no LLM call, no network dependency of any kind, same output for the same input every time. If a JSON Schema is supplied via `schema`, the extracted value is also validated against it and auto-corrected where a bounded, deterministic fix rule applies -- type coercion between string/number/boolean, filling a missing required property that has a schema-declared default, stripping properties `additionalProperties: false` disallows, case-insensitive enum matching, and clamping out-of-range numbers/arrays to their schema minimum/maximum/maxItems -- never a fuzzy or invented guess: an enum with no exact case-insensitive match, a `pattern`/`format` mismatch, or a `minItems` violation with too few real items is left as-is and reported in `remaining_issues`, never silently guessed or dropped. The response's `extraction_method`, `applied_fixes`, and `remaining_issues` fields make every transformation this tool made -- or couldn't make -- fully transparent. Useful for JSON extraction, JSON repair, cleanup, schema validation, structured-data normalization, and auto-correction of near-miss payloads (e.g. copy-pasted config, an upstream API's loosely-formatted response, a form submission). Free for the first few calls (see the platform's free-quota policy), then a small x402 payment. Free trial: 3 free calls per caller IP address, per tool, per 24 hours (and at most 50 free calls per window for this tool across all callers; MCP callers, whose address is not known, share a single anonymous free call). After that, every call is paid via x402 at $0.006 USDC per call.
Paramètres
text | string · requis | Free-form or messy text to extract structured JSON from -- already-valid JSON, JSON wrapped in prose or a markdown code fence, or malformed JSON (trailing commas, single-quoted strings, unquoted keys, a truncated array/object). |
|---|---|---|
schema | any · optionnel | Optional JSON Schema to validate the extracted value against and auto-correct where a bounded, deterministic fix rule applies. Omitted = extraction only, no validation. |
Exemple de requête
Ce que votre agent envoie
{
"text": "Sure! Here is the data: {name: 'Ada', age: 36,}"
}curl seul s'arrête au challenge 402 : ajoutez un client x402 (onglets Node.js ou Python) pour payer automatiquement.
# curl seul s'arrête au challenge 402 : ajoutez un client x402 (onglets Node.js ou Python) pour payer automatiquement.
curl -X POST 'https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json' \
-H 'content-type: application/json' \
-d '{"text":"Sure! Here is the data: {name: 'Ada', age: 36,}"}'Le SDK x402 gère le 402, la signature et le nouvel appel pour vous : un appel, un résultat.
// npm install @x402/fetch @x402/evm viem
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(signer));
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const res = await fetchWithPayment("https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({"text":"Sure! Here is the data: {name: 'Ada', age: 36,}"}),
});
console.log(await res.json());Le SDK x402 gère le 402, la signature et le nouvel appel pour vous : un appel, un résultat.
# pip install "x402[httpx]" eth_account
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
async def main() -> None:
client = x402Client()
account = Account.from_key(os.environ["EVM_PRIVATE_KEY"])
register_exact_evm_client(client, EthAccountSigner(account))
async with x402HttpxClient(client) as http:
response = await http.post("https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json", json={"text":"Sure! Here is the data: {name: 'Ada', age: 36,}"})
await response.aread()
print(response.json())
asyncio.run(main())Le client Java de référence du dépôt x402. Il n'existe pas encore de SDK Java publié : vous fournissez la signature (par exemple avec web3j).
// Reference client from github.com/coinbase/x402 (java/): build it with `mvn clean install`, then
// <dependency><groupId>org.x402</groupId><artifactId>x402</artifactId><version>1.0.0-SNAPSHOT</version></dependency>
import org.x402.client.X402HttpClient;
import org.x402.crypto.CryptoSigner;
import java.math.BigInteger;
import java.net.URI;
import java.net.http.HttpResponse;
import java.util.Map;
public class Call {
public static void main(String[] args) throws Exception {
// You provide the EIP-3009 signature (for example with web3j) from your private key (env EVM_PRIVATE_KEY).
CryptoSigner signer = new CryptoSigner() {
@Override
public String sign(Map<String, Object> payload) {
return signWithWallet(System.getenv("EVM_PRIVATE_KEY"), payload);
}
};
X402HttpClient client = new X402HttpClient(signer);
BigInteger amount = BigInteger.valueOf(6000); // $0.006 in USDC (6 decimals)
String usdcOnBase = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
String payTo = "<the seller address from the 402 challenge>";
HttpResponse<String> response = client.get(URI.create("https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json"), amount, usdcOnBase, payTo);
System.out.println(response.body());
}
}Le SDK x402 gère le 402, la signature et le nouvel appel pour vous : un appel, un résultat.
// go get github.com/x402-foundation/x402/go/v2
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"time"
"strings"
x402 "github.com/x402-foundation/x402/go/v2"
x402http "github.com/x402-foundation/x402/go/v2/http"
evm "github.com/x402-foundation/x402/go/v2/mechanisms/evm/exact/client"
evmsigners "github.com/x402-foundation/x402/go/v2/signers/evm"
)
func main() {
signer, _ := evmsigners.NewClientSignerFromPrivateKey(os.Getenv("EVM_PRIVATE_KEY"))
client := x402.Newx402Client().Register("eip155:*", evm.NewExactEvmScheme(signer))
httpClient := x402http.WrapHTTPClientWithPayment(http.DefaultClient, x402http.Newx402HTTPClient(client))
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "POST", "https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json", strings.NewReader(`{"text":"Sure! Here is the data: {name: 'Ada', age: 36,}"}`))
req.Header.Set("content-type", "application/json")
res, err := httpClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(body))
}Le SDK x402 gère le 402, la signature et le nouvel appel pour vous : un appel, un résultat.
// Cargo.toml: x402-reqwest = "0.6", x402-chain-eip155, alloy-signer-local, reqwest, tokio (features = ["full"])
use alloy_signer_local::PrivateKeySigner;
use reqwest::Client;
use std::sync::Arc;
use x402_chain_eip155::V2Eip155ExactClient;
use x402_reqwest::{ReqwestWithPayments, ReqwestWithPaymentsBuild, X402Client};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let signer: Arc<PrivateKeySigner> = Arc::new(std::env::var("EVM_PRIVATE_KEY")?.parse()?);
let x402 = X402Client::new().register(V2Eip155ExactClient::new(signer));
let http = Client::new().with_payments(x402).build();
let res = http
.post("https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json")
.header("content-type", "application/json")
.body(r#"{"text":"Sure! Here is the data: {name: 'Ada', age: 36,}"}"#)
.send()
.await?;
println!("{} {}", res.status(), res.text().await?);
Ok(())
}Ce que fait en coulisses le client x402 de votre agent (technique, illustratif).
- 1
Appeler l'endpoint
→POST https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json content-type: application/json { "text": "Sure! Here is the data: {name: 'Ada', age: 36,}" }←402 Payment RequiredHTTP/1.1 402 Payment Required PAYMENT-REQUIRED: <base64> { "x402Version": 2, "accepts": [ { "scheme": "exact", "network": "eip155:8453", "amount": "6000", "asset": "USDC", "payTo": "0x…" } ] } - 2
Signer le paiement (local)
Votre wallet signe localement une autorisation USDC. Seule la signature quitte votre machine.
→wallet.sign(transferWithAuthorization, to: payTo, value: 6000 ($0.006 USDC), network: base)←signaturePAYMENT-SIGNATURE: <signed authorisation> - 3
Rejouer avec la signature
→POST https://api.17711.xyz/registry/extract-correct-service/v1/extract-correct/parse_json PAYMENT-SIGNATURE: <signed authorisation> content-type: application/json { "text": "Sure! Here is the data: {name: 'Ada', age: 36,}" }←200 OKHTTP/1.1 200 OK PAYMENT-RESPONSE: <settlement receipt> { … the tool's JSON answer … }
Le SDK x402 fait les étapes 2 et 3 pour vous.
Définition OpenAPI
Définition OpenAPI · extract_correct_parse_json
{
"operationId": "extract_correct_parse_json",
"summary": "JSON repair: extracts structured JSON from messy text or LLM output, optionally validating and auto-correcting it against a JSON Schema ($0.006, x402)",
"description": "Reads free-form or messy text -- already-valid JSON, JSON wrapped in prose or a markdown code fence, or malformed JSON (trailing commas, single-quoted strings, unquoted keys, a truncated array/object) -- and returns the extracted structured JSON value. 100% local, deterministic extraction and repair (a classical JSON-repair algorithm plus a hand-written balanced-bracket scanner) -- no LLM call, no network dependency of any kind, same output for the same input every time. If a JSON Schema is supplied via `schema`, the extracted value is also validated against it and auto-corrected where a bounded, deterministic fix rule applies -- type coercion between string/number/boolean, filling a missing required property that has a schema-declared default, stripping properties `additionalProperties: false` disallows, case-insensitive enum matching, and clamping out-of-range numbers/arrays to their schema minimum/maximum/maxItems -- never a fuzzy or invented guess: an enum with no exact case-insensitive match, a `pattern`/`format` mismatch, or a `minItems` violation with too few real items is left as-is and reported in `remaining_issues`, never silently guessed or dropped. The response's `extraction_method`, `applied_fixes`, and `remaining_issues` fields make every transformation this tool made -- or couldn't make -- fully transparent. Useful for JSON extraction, JSON repair, cleanup, schema validation, structured-data normalization, and auto-correction of near-miss payloads (e.g. copy-pasted config, an upstream API's loosely-formatted response, a form submission). Free for the first few calls (see the platform's free-quota policy), then a small x402 payment. Free trial: 3 free calls per caller IP address, per tool, per 24 hours (and at most 50 free calls per window for this tool across all callers; MCP callers, whose address is not known, share a single anonymous free call). After that, every call is paid via x402 at $0.006 USDC per call.",
"x-price-usdc": "0.006",
"x-payment-info": {
"price": {
"mode": "fixed",
"currency": "USD",
"amount": "0.006000"
},
"protocols": [
{
"x402": {}
}
]
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Free-form or messy text to extract structured JSON from -- already-valid JSON, JSON wrapped in prose or a markdown code fence, or malformed JSON (trailing commas, single-quoted strings, unquoted keys, a truncated array/object)."
},
"schema": {
"description": "Optional JSON Schema to validate the extracted value against and auto-correct where a bounded, deterministic fix rule applies. Omitted = extraction only, no validation."
}
},
"required": [
"text"
]
},
"example": {
"text": "string",
"schema": null
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"description": "The extracted (and, if a schema was supplied, corrected) JSON value."
},
"extraction_method": {
"type": "string",
"description": "How `data` was obtained: `\"direct\"` (already valid JSON), `\"repaired\"` (malformed JSON fixed in place), or `\"extracted_and_repaired\"` (isolated from surrounding text, then fixed)."
},
"valid": {
"description": "Whether `data` satisfies `schema` after correction. `None` when no `schema` was supplied -- never conflated with \"assumed valid\".",
"type": [
"boolean",
"null"
]
},
"applied_fixes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "JSON Pointer to the field that was corrected (e.g. `/user/age`; `\"\"` = the whole value)."
},
"rule": {
"type": "string",
"description": "Which bounded correction rule fired (e.g. `type_coercion`, `additional_property_stripped`, `enum_case_insensitive_match`, `required_default_filled`, `clamped_to_minimum`, `clamped_to_maximum`, `array_truncated_to_max_items`)."
},
"detail": {
"type": "string",
"description": "Human-readable detail of what changed."
}
},
"required": [
"path",
"rule",
"detail"
],
"description": "One deterministic correction actually applied to the extracted value."
},
"description": "Every correction actually applied, in the order applied."
},
"remaining_issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "JSON Pointer to the field that still fails validation."
},
"keyword": {
"type": "string",
"description": "The JSON Schema keyword that failed (e.g. `pattern`, `format`, `minItems`, `oneOf`)."
},
"message": {
"type": "string",
"description": "The underlying validator's own error message."
}
},
"required": [
"path",
"keyword",
"message"
],
"description": "One schema violation that could NOT be corrected -- never silently dropped or guessed."
},
"description": "Every schema violation that remains after correction -- non-empty only when `schema` was supplied and at least one issue couldn't be fixed by a bounded v1 rule."
}
},
"required": [
"data",
"extraction_method",
"applied_fixes",
"remaining_issues"
]
},
"example": {
"data": null,
"extraction_method": "string",
"valid": false,
"applied_fixes": [
{
"path": "string",
"rule": "string",
"detail": "string"
}
],
"remaining_issues": [
{
"path": "string",
"keyword": "string",
"message": "string"
}
]
}
}
}
},
"402": {
"description": "Payment required -- a free-call quota exists (default 5 calls, see PLATFORM_FREEMIUM_FREE_CALLS) before this status applies; beyond it, pay via the real x402 protocol (PAYMENT-REQUIRED response header, decode and retry with a signed PAYMENT-SIGNATURE header).",
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "x402 v2 PaymentRequired challenge",
"properties": {
"x402Version": {
"type": "integer"
},
"error": {
"type": "string"
},
"resource": {
"type": "object",
"properties": {
"url": {
"type": "string"
},
"description": {
"type": "string"
},
"mimeType": {
"type": "string"
}
}
},
"accepts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"scheme": {
"type": "string"
},
"network": {
"type": "string"
},
"amount": {
"type": "string",
"description": "Token atomic units, NOT decimal USD -- see x-payment-info.price.amount for the decimal form."
},
"asset": {
"type": "string"
},
"payTo": {
"type": "string"
},
"maxTimeoutSeconds": {
"type": "integer"
},
"extra": {
"type": "object"
}
}
}
}
},
"required": [
"x402Version",
"accepts"
]
}
}
}
},
"default": {
"description": "Standardized error envelope, on every non-2xx response from this fleet: {\"error\": {\"code\": <dotted string, e.g. \"request.bad_request\">, \"index\": <integer>, \"status\": <HTTP status code>, \"message\": <client-safe description>, \"debug\": <object, present only for an authorized caller>}}.",
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "ErrorEnvelope"
}
}
}
}
}
}