/** * Indents a flat JSON string to make it more human-readable * * @return string */ public function format() { $json = (string) $this->getParameter('value'); if (empty($json)) { return '""'; } $html = (bool) $this->getParameter('html'); return JSONUtils::format($json, $html); }
/** * @dataProvider getTestTypes * * @param array $phpArray * @param string $json * @param string $pretty */ public function testCompareTypes(array $phpArray, $json, $pretty) { $this->assertJsonStringEqualsJsonString(\JSONUtils::encode($phpArray), $json); $this->assertJsonStringEqualsJsonString(\JSONUtils::encode($phpArray, true), $pretty); $this->assertJsonStringEqualsJsonString(\JSONUtils::format($json), $pretty); }