Fixes #957: Json::encode() doesn't handle empty object correctly.

This commit is contained in:
Qiang Xue
2013-10-09 20:33:06 -04:00
parent aede3c9f47
commit fceb2d6e21
2 changed files with 18 additions and 20 deletions

View File

@ -45,6 +45,10 @@ class JsonTest extends TestCase
'b' => new JsExpression($expression2),
);
$this->assertSame("{\"a\":[1,$expression1],\"b\":$expression2}", Json::encode($data));
// https://github.com/yiisoft/yii2/issues/957
$data = (object)null;
$this->assertSame('{}', Json::encode($data));
}
public function testDecode()