source:
node_modules/es-toolkit/dist/predicate/isJSON.mjs
| Last change on this file was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 216 bytes | |
| Rev | Line | |
|---|---|---|
| [a762898] | 1 | function isJSON(value) { |
| 2 | if (typeof value !== 'string') { | |
| 3 | return false; | |
| 4 | } | |
| 5 | try { | |
| 6 | JSON.parse(value); | |
| 7 | return true; | |
| 8 | } | |
| 9 | catch { | |
| 10 | return false; | |
| 11 | } | |
| 12 | } | |
| 13 | ||
| 14 | export { isJSON }; |
Note:
See TracBrowser
for help on using the repository browser.
