feat(utils): add safe json parsing utility

Add safeParseJson function to handle JSON parsing with error catching
This commit is contained in:
icarus 2025-10-20 22:45:51 +08:00
parent e7e36d7df6
commit 917864be1c
2 changed files with 8 additions and 0 deletions

View File

@ -1 +1,2 @@
export * from './json'
export * from './net'

View File

@ -0,0 +1,7 @@
export function safeParseJson(text: string): unknown | null {
try {
return JSON.parse(text)
} catch {
return null
}
}