Add jsonPrettyPrint for formatted JSON output

Can be used for any debug output when needed
This commit is contained in:
Clemens Schwaighofer
2025-06-04 15:09:20 +09:00
parent d4db235e5b
commit a501fa25de
2 changed files with 19 additions and 0 deletions

View File

@@ -119,6 +119,23 @@ class Json
}
return $return_string === true ? $json_error_string : self::$json_last_error;
}
/**
* wrapper to call convert array to json with pretty print
*
* @param array<mixed> $data
* @return string
*/
public static function jsonPrettyPrint(array $data): string
{
return self::jsonConvertArrayTo(
$data,
JSON_PRETTY_PRINT |
JSON_UNESCAPED_LINE_TERMINATORS |
JSON_UNESCAPED_SLASHES |
JSON_UNESCAPED_UNICODE
);
}
}
// __END__