|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60924 ArrayObject should implement JsonSerializable interface
Submitted: 2012-01-29 17:45 UTC Modified: -
Avg. Score:4.6 ± 1.0
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:4 (66.7%)
From: chris at cmbuckley dot co dot uk Assigned:
Status: Open Package: Class/Object related
PHP Version: 5.4.0RC6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chris at cmbuckley dot co dot uk
New email:
PHP Version: OS:


 [2012-01-29 17:45 UTC] chris at cmbuckley dot co dot uk
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($ao instanceof JsonSerializable);

Expected result:
string(13) "{"foo":"bar"}"
string(13) "{"foo":"bar"}"

Actual result:
string(13) "{"foo":"bar"}"
PHP Fatal error:  Call to undefined method ArrayObject::jsonSerialize() in - on line 6


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Oct 20 21:01:23 2020 UTC