diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 695679d1d..16d3d3394 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -237,7 +237,7 @@ class JsonFile } } else { // Collapse empty {} and [] - $result = rtrim($result); + $result = rtrim($result)."\n\n".$indentStr; } } diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php index 4e30928cb..159017aa6 100644 --- a/tests/Composer/Test/Json/JsonFileTest.php +++ b/tests/Composer/Test/Json/JsonFileTest.php @@ -128,6 +128,20 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase $this->assertJsonFormat($json, $data); } + public function testFormatEmptyArray() + { + $data = array('test' => array(), 'test2' => new \stdClass); + $json = '{ + "test": [ + + ], + "test2": { + + } +}'; + $this->assertJsonFormat($json, $data); + } + public function testEscape() { $data = array("Metadata\\\"" => 'src/');