curl -X POST https://json-api.barotov.com/v1 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"json": "{\"user\": \"alex\", \"role\": \"admin\",}",
"schema": { "type": "object", "required": ["user"] },
"minify": true
}'
const res = await fetch('https://json-api.barotov.com/v1', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
json: '{"user": "alex", "role": "admin",}',
schema: { type: "object", required: ["user"] },
minify: true
})
});
const data = await res.json();
console.log(data.text); // Minified & Repaired JSON
interface RepairResponse {
valid: boolean;
repaired: boolean;
json: any;
text: string;
}
const res = await fetch('https://json-api.barotov.com/v1', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
json: '{"user": "alex", "role": "admin",}',
minify: true
})
});
const data: RepairResponse = await res.json();
console.log(data.text);
import { z } from 'zod';
const UserSchema = z.object({
user: z.string(),
role: z.string(),
});
// Convert Zod schema to JSON Schema for the API using native toJSONSchema
const jsonSchema = z.toJSONSchema(UserSchema);
const res = await fetch('https://json-api.barotov.com/v1', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
json: '{"user": "alex", "role": "admin",}',
schema: jsonSchema, // API validates using this
minify: true
})
});
const data = await res.json();
console.log(data.valid); // true
import requests
url = "https://json-api.barotov.com/v1"
payload = {
"json": '{"user": "alex", "role": "admin",}',
"minify": True
}
headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.post(url, json=payload, headers=headers)
print(response.json()["text"])
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://json-api.barotov.com/v1"
payload := map[string]interface{}{
"json": "{\"user\": \"alex\", \"role\": \"admin\",}",
"minify": true,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}
require 'net/http'
require 'json'
require 'uri'
uri = URI.parse("https://json-api.barotov.com/v1")
header = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
}
payload = {
json: '{"user": "alex", "role": "admin",}',
minify: true
}
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = payload.to_json
response = http.request(request)
puts JSON.parse(response.body)["text"]
use LWP::UserAgent;
use JSON;
my $ua = LWP::UserAgent->new;
my $url = 'https://json-api.barotov.com/v1';
my $payload = {
json => '{"user": "alex", "role": "admin",}',
minify => 1
};
my $req = HTTP::Request->new(POST => $url);
$req->header('Content-Type' => 'application/json');
$req->header('Authorization' => 'Bearer YOUR_API_KEY');
$req->content(encode_json($payload));
my $resp = $ua->request($req);
if ($resp->is_success) {
print decode_json($resp->content)->{text};
}