UNPKG

universal-fs

Version:

Allows a client or server to access the file system in the current codebase or a different one.

16 lines (14 loc) 298 B
/** * Check if a string is json * @param str The string to check * @returns A boolean if true the string is valid otherwise false */ const isJson = (str: string): boolean => { try { JSON.parse(str); return true; } catch (err: any) { return false; } }; export default isJson;