1
0
Fork 0

Fix 5.4.0 interop in formatting of empty array/objects

pull/636/merge
Jordi Boggiano 2012-04-29 21:04:18 +02:00
parent 58276d0a52
commit a30e6109bf
2 changed files with 15 additions and 1 deletions

View File

@ -237,7 +237,7 @@ class JsonFile
} }
} else { } else {
// Collapse empty {} and [] // Collapse empty {} and []
$result = rtrim($result); $result = rtrim($result)."\n\n".$indentStr;
} }
} }

View File

@ -128,6 +128,20 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase
$this->assertJsonFormat($json, $data); $this->assertJsonFormat($json, $data);
} }
public function testFormatEmptyArray()
{
$data = array('test' => array(), 'test2' => new \stdClass);
$json = '{
"test": [
],
"test2": {
}
}';
$this->assertJsonFormat($json, $data);
}
public function testEscape() public function testEscape()
{ {
$data = array("Metadata\\\"" => 'src/'); $data = array("Metadata\\\"" => 'src/');