Resolve PHP json decode error
Jump to navigation
Jump to search
Syntax error, malformed JSON
Possible causes
- the input is empty or multiple white spaces
- the input contains Byte order mark (BOM)[1]
Solution:
- Not allowed empty input
- Remove Byte order mark (BOM)
- Use JSONLint - The JSON Validator to validate the JSON format
Unexpected control character found
Possible causes
- the input string contains control characters
Solution:
- Remove control character
$replacement = '';
preg_replace('/[\x00-\x1F]/', $replacement, $input);