# API04003: Malformed JSON Response

## What This Means[​](#what-this-means "Direct link to What This Means")

The server returned data that appears to be JSON but is corrupted or invalid. The POS couldn't parse the response because the JSON syntax is broken.

## Common Causes[​](#common-causes "Direct link to Common Causes")

* **PHP notices/warnings** — PHP output before the JSON
* **BOM (Byte Order Mark)** — Invisible characters at file start
* **Encoding issues** — Character encoding problems
* **Truncated response** — Response cut off mid-transmission
* **Plugin output** — A plugin added non-JSON content

## How to Fix[​](#how-to-fix "Direct link to How to Fix")

### 1. Check for PHP Notices[​](#1-check-for-php-notices "Direct link to 1. Check for PHP Notices")

PHP notices/warnings before JSON break parsing:

In `wp-config.php`:

```
define('WP_DEBUG', true);

define('WP_DEBUG_LOG', true);

define('WP_DEBUG_DISPLAY', false);
```

Review `wp-content/debug.log` and fix any issues.

### 2. Check for BOM Characters[​](#2-check-for-bom-characters "Direct link to 2. Check for BOM Characters")

Some text editors add invisible BOM characters:

* Re-save PHP files without BOM
* Use UTF-8 without BOM encoding
* Check recently edited files

### 3. Verify Complete Response[​](#3-verify-complete-response "Direct link to 3. Verify Complete Response")

If responses are being truncated:

* Check PHP output buffering settings
* Increase `output_buffering` in php.ini
* Check for timeout issues

### 4. Test API Directly[​](#4-test-api-directly "Direct link to 4. Test API Directly")

In your browser or using curl:

```
curl -v https://yoursite.com/wp-json/wcpos/v1/
```

Look for any unexpected content before the JSON.

### 5. Check Character Encoding[​](#5-check-character-encoding "Direct link to 5. Check Character Encoding")

Ensure database and PHP use UTF-8:

* Check `wp-config.php` charset settings
* Verify database tables are UTF-8
* Look for special characters causing issues

## Related Errors[​](#related-errors "Direct link to Related Errors")

* [API04001](/error-codes/API04001.md) — Invalid Response Format
* [API04005](/error-codes/API04005.md) — JSON Recovery Attempted
