Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Zend_Json
Description
When a class implement the method toJson, Zend_Json::encode (using the builtin encoder) should call this method when encoding object in the structure.
Here is a code sample :
<?php
set_include_path('/home/sylvain/src/ZendFramework/library');
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();
class JsonEncodable {
public function toJson() {
return '"Encodable object"';
}
}
$struct = array(
'encodable_object' => new JsonEncodable()
);
Zend_Json::$useBuiltinEncoderDecoder = true;
echo Zend_Json::encode($struct);
This code should return :
{"encodable_object":"Encodable object"}
Attachments
Issue Links
| This issue duplicates: | ||||
| ZF-9521 | Encoding array of objects implementing toJson() method |
|
|
|
Here is my implementation of the patch