mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-12-02 13:04:08 +01:00
Better formatting
This commit is contained in:
1 parent
e53693f605
commit
d31255d987
2 files changed
+15
-4
No files matched your search
@@ -1,6 +1,7 @@
|
||||
export function tryFormatJson(text: string): string {
|
||||
export function tryFormatJson(text: string, pretty = true): string {
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(text), null, 2);
|
||||
if (pretty) return JSON.stringify(JSON.parse(text), null, 2);
|
||||
else return JSON.stringify(JSON.parse(text));
|
||||
} catch (_) {
|
||||
return text;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user