mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 11:21:16 +01:00
Better formatting
This commit is contained in:
@@ -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