mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 08:36:40 +01:00
9 lines
232 B
TypeScript
9 lines
232 B
TypeScript
export function tryFormatJson(text: string, pretty = true): string {
|
|
try {
|
|
if (pretty) return JSON.stringify(JSON.parse(text), null, 2);
|
|
else return JSON.stringify(JSON.parse(text));
|
|
} catch (_) {
|
|
return text;
|
|
}
|
|
}
|