Commit 157b1ffd by Qiang Xue

Merge pull request #1568 from cebe/jsonserializable

Json::encode did not handle JsonSerializable objects
parents a4fe805c 060775b0
...@@ -11,6 +11,7 @@ Yii Framework 2 Change Log ...@@ -11,6 +11,7 @@ Yii Framework 2 Change Log
- Bug #1545: It was not possible to execute db Query twice, params where missing (cebe) - Bug #1545: It was not possible to execute db Query twice, params where missing (cebe)
- Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark) - Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark)
- Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark) - Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark)
- Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe)
- Enh #1293: Replaced Console::showProgress() with a better approach. See Console::startProgress() for details (cebe) - Enh #1293: Replaced Console::showProgress() with a better approach. See Console::startProgress() for details (cebe)
- Enh #1406: DB Schema support for Oracle Database (p0larbeer, qiangxue) - Enh #1406: DB Schema support for Oracle Database (p0larbeer, qiangxue)
- Enh #1437: Added ListView::viewParams (qiangxue) - Enh #1437: Added ListView::viewParams (qiangxue)
......
...@@ -81,6 +81,10 @@ class BaseJson ...@@ -81,6 +81,10 @@ class BaseJson
*/ */
protected static function processData($data, &$expressions, $expPrefix) protected static function processData($data, &$expressions, $expPrefix)
{ {
if ($data instanceof \JsonSerializable) {
return $data;
}
if (is_object($data)) { if (is_object($data)) {
if ($data instanceof JsExpression) { if ($data instanceof JsExpression) {
$token = "!{[$expPrefix=" . count($expressions) . ']}!'; $token = "!{[$expPrefix=" . count($expressions) . ']}!';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment