Resolve PHP json decode error: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
(Created page with " == Syntax error, malformed JSON == Possible causes * the input is empty or multiple white spaces * the input contains Byte order mark (BOM)<ref>[https://blog.longwin.com....")
 
Line 15: Line 15:


Solution:
Solution:
* Remove control character
* Remove control character. Using PHP:


<pre>
<pre>

Revision as of 14:43, 12 April 2019

Syntax error, malformed JSON

Possible causes

Solution:

Unexpected control character found

Possible causes

Solution:

  • Remove control character. Using PHP:
$replacement = '';
preg_replace('/[\x00-\x1F]/', $replacement, $input);

References

Relates articles