JSON Unescape API Documentation¶
Overview¶
The JSON Unescape API converts an escaped JSON string literal back into its raw JSON text.
It validates both the escaped input and the resulting unescaped JSON to ensure correctness.
This tool supports Body, URL, and File input modes and returns a downloadable JSON file.
Endpoint (POST)¶
POST https://api.apidatatools.com/json-unescape-api
Headers¶
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key | string | Yes | Your API key for authentication |
Content-Type | string | Yes | Must be application/json |
x-source-type | string | Optional | One of body, url, or file (default: body) |
Accepted File Extensions¶
| Mode | Allowed Extensions |
|---|---|
| URL / File | .txt, .json, .log |
Input Example (Body Mode)¶
"\"{ \\\"name\\\": \\\"John\\\", \\\"age\\\": 30 }\""
The input must be a JSON string literal containing escaped JSON content.
Input Example (URL Mode)¶
{
"url": "https://example.com/sample.json"
}
Input Example (File Mode)¶
{
"file": "user_uploads/escaped_json.txt"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/json-unescape-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: body" \
-d "\"{ \\\"name\\\": \\\"John\\\", \\\"age\\\": 30 }\""
Asynchronous (Remote File URL)¶
curl -X POST "https://api.apidatatools.com/json-unescape-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: url" \
-d '{"url": "https://example.com/escaped_json.json"}'
Asynchronous (Input File)¶
curl -X POST "https://api.apidatatools.com/json-unescape-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "x-source-type: file" \
-d '{"file": "uploads/escaped_json.txt"}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "b2a1f0c3-1234-4e7a-8a9b-9f1e2d3c4b5a",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.json",
"preview": "{ \"name\": \"John\", \"age\": 30 }"
}
Async Job Accepted¶
{
"status": "accepted",
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status_url": "https://api.apidatatools.com/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"request_id": "b2a1f0c3-1234-4e7a-8a9b-9f1e2d3c4b5a"
}
Error Handling¶
| Error Code | HTTP Status | Description | Example |
|---|---|---|---|
INVALID_ESCAPED_JSON | 400 | Input is not a valid JSON string literal. | { "status": "error", "error": "INVALID_ESCAPED_JSON", "details": { "message": "Input must be a valid JSON string literal." } } |
INVALID_RAW_JSON | 400 | The unescaped string is not valid JSON. | { "status": "error", "error": "INVALID_RAW_JSON", "details": { "message": "Unescaped string is not valid JSON." } } |
INVALID_URL | 400 | Invalid or missing URL in URL mode. | { "status": "error", "error": "INVALID_URL", "details": { "message": "URL must be valid http/https." } } |
URL_UNREACHABLE | 400 | The provided URL could not be reached. | { "status": "error", "error": "URL_UNREACHABLE", "details": { "message": "Could not reach URL." } } |
URL_NOT_OK | 400 | Remote URL did not return HTTP 200. | { "status": "error", "error": "URL_NOT_OK", "details": { "message": "URL returned HTTP 404, expected 200." } } |
FILE_TOO_LARGE | 413 | File exceeds plan limit. | { "status": "error", "error": "FILE_TOO_LARGE", "details": { "message": "Remote file exceeds plan limit." } } |
INVALID_FILE | 400 | Missing or invalid file path in file mode. | { "status": "error", "error": "INVALID_FILE", "details": { "message": "Missing or invalid 'file'." } } |
INVALID_FILE_EXTENSION | 400 | File extension not supported. | { "status": "error", "error": "INVALID_FILE_EXTENSION", "details": { "message": "Invalid or unsupported file extension." } } |
PAYLOAD_TOO_LARGE | 413 | Request body exceeds plan limit. | { "status": "error", "error": "PAYLOAD_TOO_LARGE", "details": { "message": "Request body exceeds allowed size." } } |
INTERNAL_ERROR | 500 | Unexpected internal error. | { "status": "error", "error": "INTERNAL_ERROR", "details": { "message": "Failed to process your request" } } |
Async Job Status¶
To check the status of an asynchronous job (URL or File mode):
Endpoint:
GET https://api.apidatatools.com/jobs/{job_id}
Example Status Response for Async¶
Queued¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "queued",
"created_at": 1712345678,
"updated_at": 1712345678,
"message": "Your job is being processed.",
"retry_after": 2
}
Success¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "success",
"created_at": 1712345678,
"updated_at": 1712345690,
"result": {
"status": "success",
"file": "https://downloads.apidatatools.com/apidatatools_convert_abc123.json",
"request_id": "b2a1f0c3-1234-4e7a-8a9b-9f1e2d3c4b5a",
"preview": "{ \"name\": \"John\", \"age\": 30 }"
}
}
Failed¶
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "failed",
"created_at": 1712345678,
"updated_at": 1712345690,
"error": {
"code": "INVALID_RAW_JSON",
"message": "Unescaped string is not valid JSON.",
"details": {
"message": "Unescaped string is not valid JSON."
}
}
}
Notes for Developers¶
- The output is always a JSON file uploaded to a secure storage location.
- For large inputs or remote files, use
x-source-type: urlorx-source-type: fileto trigger asynchronous processing. - Each response includes a unique
request_idfor traceability. - Async jobs can be tracked using the provided
status_url. - Allowed extensions for URL/File mode are
.txt,.json, and.log. - The preview field in responses is limited to the first 100 KB of the output.