This commit is contained in:
张成
2026-03-18 14:18:41 +08:00
parent 54341f0a0b
commit 5b671d320b
21 changed files with 4404 additions and 42 deletions

View File

@@ -0,0 +1,18 @@
export function safe_json_stringify(value) {
try {
return JSON.stringify(value);
} catch (err) {
return JSON.stringify({ error: 'json_stringify_failed', message: String(err) });
}
}
export function safe_json_parse(text) {
if (text === null || text === undefined || text === '') {
return null;
}
try {
return JSON.parse(text);
} catch (err) {
return null;
}
}