Index: library/Zend/Json/Encoder.php =================================================================== --- library/Zend/Json/Encoder.php (revision 24101) +++ library/Zend/Json/Encoder.php (working copy) @@ -151,7 +151,8 @@ } } - return '{"__className":"' . get_class($value) . '"' + $className = get_class($value); + return '{"__className":' . $this->_encodeString($className) . $props . '}'; } Index: tests/Zend/JsonTest.php =================================================================== --- tests/Zend/JsonTest.php (revision 24101) +++ tests/Zend/JsonTest.php (working copy) @@ -762,6 +762,25 @@ $expectedDecoding = '{"__className":"ArrayIterator","0":"foo"}'; $this->assertEquals($encoded, $expectedDecoding); } + + /** + * @group ZF-11356 + */ + public function testEncoderEscapesNamespacedClassNamesProperly() + { + if (version_compare(PHP_VERSION, '5.3.0') === -1) { + $this->markTestSkipped('Namespaces not available in PHP < 5.3.0'); + } + + require_once dirname(__FILE__ ) . "/Json/_files/Zf11356-NamespacedClass.php"; + $inputValue = new \Zend\JsonTest\Zf11356\NamespacedClass(array('foo')); + + $encoded = Zend_Json_Encoder::encode($inputValue); + $this->assertEquals( + '{"__className":"Zend\\\\JsonTest\\\\Zf11356\\\\NamespacedClass","0":"foo"}', + $encoded + ); + } } /** Index: tests/Zend/Json/_files/Zf11356-NamespacedClass.php =================================================================== --- tests/Zend/Json/_files/Zf11356-NamespacedClass.php (revision 0) +++ tests/Zend/Json/_files/Zf11356-NamespacedClass.php (revision 0) @@ -0,0 +1,34 @@ +