UNPKG

@kangfenmao/keyv-storage

Version:

Simple key-value storage with support for multiple backends

16 lines (14 loc) 268 B
/** * 判断字符串是否是 json 字符串 * @param str 字符串 */ export function isJSON(str: any): boolean { if (typeof str !== 'string') { return false } try { return typeof JSON.parse(str) === 'object' } catch (e) { return false } }