mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 12:51:26 +08:00
feat(utils): add safe json parsing utility
Add safeParseJson function to handle JSON parsing with error catching
This commit is contained in:
parent
e7e36d7df6
commit
917864be1c
@ -1 +1,2 @@
|
||||
export * from './json'
|
||||
export * from './net'
|
||||
|
||||
7
packages/shared/utils/json.ts
Normal file
7
packages/shared/utils/json.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export function safeParseJson(text: string): unknown | null {
|
||||
try {
|
||||
return JSON.parse(text)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user