Пример #1
0
 /**
  * @test
  * @group library
  */
 public function prettyPrintSuccess()
 {
     $json = '{"foo":"bar","bar":"foo","world":42,"expectNull":null,"expectEmptyArray":[],"expectEmptyObject":{},"expectArray":["data"],"expectObject":{"hasData":true}}';
     $excpetedPrettyPrint = "{\n    \"foo\":\"bar\",\n    \"bar\":\"foo\",\n    \"world\":42,\n" . "    \"expectNull\":null,\n" . "    \"expectEmptyArray\":[\n        \n    ],\n" . "    \"expectEmptyObject\":{\n        \n    },\n" . "    \"expectArray\":[\n        \"data\"\n    ],\n" . "    \"expectObject\":{\n        \"hasData\":true\n    }\n}";
     $actualPrettyPrint = SbJson::prettyPrint($json, '    ');
     $this->assertEquals($excpetedPrettyPrint, $actualPrettyPrint);
 }
Пример #2
0
 /**
  * @param string $moduleDataDirectory
  * @param string $filename
  * @param mixed  $data
  *
  * @throws SbJson\JsonException
  * @throws \Exception
  */
 protected function storeJsonFile($moduleDataDirectory, $filename, $data)
 {
     $dataJson = SbJson::prettyPrint(SbJson::encode($data));
     $this->setFileContent($moduleDataDirectory, $filename, $dataJson);
 }