feat(SW-977) check if json is valid
This commit is contained in:
9
utils/isValidJson.ts
Normal file
9
utils/isValidJson.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function isValidJson(value: string | null | undefined): boolean {
|
||||
if (!value || value === "undefined") return false
|
||||
try {
|
||||
JSON.parse(value)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user