Index: tests/Zend/JsonTest.php =================================================================== --- tests/Zend/JsonTest.php (revision 22219) +++ tests/Zend/JsonTest.php (working copy) @@ -755,6 +755,18 @@ { Zend_Json::decode(' some string '); } + + /** + * @group ZF-9416 + * Encoding an iterator using the internal encoder should handle undefined keys + */ + public function testIteratorWithoutDefinedKey() + { + $inputValue = new ArrayIterator(array('foo')); + $encoded = Zend_Json_Encoder::encode($inputValue); + $expectedDecoding = '{"__className":"ArrayIterator","0":"foo"}'; + $this->assertEquals($encoded, $expectedDecoding); + } } /** Index: library/Zend/Json/Encoder.php =================================================================== --- library/Zend/Json/Encoder.php (revision 22219) +++ library/Zend/Json/Encoder.php (working copy) @@ -145,7 +145,7 @@ foreach ($propCollection as $name => $propValue) { if (isset($propValue)) { $props .= ',' - . $this->_encodeValue($name) + . $this->_encodeString($name) . ':' . $this->_encodeValue($propValue); }