|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-12-07 15:41 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Package: Class/Object related
+Package: SPL related
-Assigned To:
+Assigned To: cmb
[2020-12-07 15:41 UTC] cmb@php.net
[2020-12-07 18:02 UTC] chris at cmbuckley dot co dot uk
-Status: Feedback
+Status: Assigned
[2020-12-07 18:02 UTC] chris at cmbuckley dot co dot uk
[2020-12-07 18:13 UTC] cmb@php.net
-Status: Assigned
+Status: Closed
[2020-12-07 18:13 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 01:00:01 2025 UTC |
Description: ------------ PHP 5.4 brings the new JsonSerializable interface. ArrayObject already works with json_encode as expected but does not explicitly implement this interface. Test script: --------------- $ao = new ArrayObject(array('foo' => 'bar')); var_dump(json_encode($ao)); var_dump($ao instanceof JsonSerializable); var_dump($ao->jsonSerialize()); Expected result: ---------------- string(13) "{"foo":"bar"}" bool(true) string(13) "{"foo":"bar"}" Actual result: -------------- string(13) "{"foo":"bar"}" bool(false) PHP Fatal error: Call to undefined method ArrayObject::jsonSerialize() in - on line 6