ZF-12347: Zend_Json_Encoder doesn't support IteratorAggregate
Description
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);
Comments
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: https://github.com/zendframework/zf2/pull/2061
Posted by Rob Allen (rob) on 2012-11-02T21:01:34.000+0000
Applied patch to trunk (25058) and release-1.12 (25059)