ZF-12347: Zend_Json_Encoder doesn't support IteratorAggregate

Issue Type: Patch Created: 2012-07-25T11:43:23.000+0000 Last Updated: 2012-12-18T20:08:27.000+0000 Status: Resolved Fix version(s): - 1.12.1 (18/Dec/12)

Reporter: Peter van der Wal ( Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Json

  • FixForZF1.12
  • state:patch-ready-for-review
  • zf-caretaker-adamlundrigan

Related issues: Attachments: - ZF-12347.patch


Zend_Json_Encoder only traverses over objects of type Iterator, but not of type IteratorAggregate

--- library/Zend/Json/Encoder.php (revision 25022) +++ library/Zend/Json/Encoder.php (working copy) @@ -138,7 +138,7 @@ if (method_exists($value, 'toJson')) { $props =',' . preg_replace("/^{(.*)}$/","\1",$value->toJson()); } else { - if ($value instanceof Iterator) { + if ($value instanceof Traversable) { $propCollection = $value; } else { $propCollection = get_object_vars($value);


Posted by Adam Lundrigan (adamlundrigan) on 2012-07-31T12:10:22.000+0000

Attached patch implementing handling of IteratorAggregate

Posted by Adam Lundrigan (adamlundrigan) on 2012-07-31T13:49:18.000+0000

ZF2 Pull Request:

Posted by Rob Allen (rob) on 2012-11-02T21:01:34.000+0000

Applied patch to trunk (25058) and release-1.12 (25059)

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.