Files
chat/client/shared/utils/json-helper.ts

17 lines
293 B
TypeScript
Raw Permalink Normal View History

2026-04-25 16:36:34 +08:00
/**
* json字符串
* @param jsonStr json字符串
*/
export function isValidJson(jsonStr: string): boolean {
if (typeof jsonStr !== 'string') {
return false;
}
try {
JSON.parse(jsonStr);
return true;
} catch (e) {
return false;
}
}