u
This commit is contained in:
1 parent
bcc4722efc
commit
f48536774f
403 files changed
+34776
No files matched your search
@@ -0,0 +1,16 @@
|
||||
export function toJson(obj: any): string {
|
||||
try {
|
||||
return JSON.stringify(obj);
|
||||
} catch (error) {
|
||||
console.error("JSON 转换失败", error);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
export function toObject<T>(json: string): T | null {
|
||||
try {
|
||||
return JSON.parse(json) as T;
|
||||
} catch (error) {
|
||||
console.error("JSON 解析失败", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user