public function jsonEncodePretty($value, $indent = 4) { $json = json_encode($value, JSON_PRETTY_PRINT); if ("[\n\n]" === $json) { $json = '{}'; } if (4 !== $indent) { $json = str_replace(' ', str_repeat(' ', $indent), $json); } return $json; }