|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-21 09:09 UTC] scottmac@php.net
[2011-02-21 09:09 UTC] scottmac@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: scottmac
[2011-02-21 09:09 UTC] scottmac@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
Description: ------------ json_last_error() doesn't work properly in arrays/objects. If an error occurs when encoding a property/key, and it isn't the LAST property/key, json_last_error() is reset to 0. json_last_error() should report the last parsing error from the last json_encode() call AS AN ENTIRETY, not the last internal encoding step that takes place inside the function. Test script: --------------- $bad_utf8 = quoted_printable_decode('=B0'); json_encode($bad_utf8); print "ERROR: " . json_last_error() . "\n"; $a = new stdclass; $a->foo = quoted_printable_decode('=B0'); json_encode($a); print "ERROR: " . json_last_error() . "\n"; $b = new stdclass; $b->foo = $bad_utf8; $b->bar = 1; json_encode($b); print "ERROR: " . json_last_error() . "\n"; $c = array( 'foo' => $bad_utf8, 'bar' => 1 ); json_encode($c); print "ERROR: " . json_last_error() . "\n"; Expected result: ---------------- ERROR: 5 ERROR: 5 ERROR: 5 ERROR: 5 Actual result: -------------- ERROR: 5 ERROR: 5 ERROR: 0 ERROR: 0