UNPKG

869 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = isJSON;
7
8var _assertString = _interopRequireDefault(require("./util/assertString"));
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13
14function isJSON(str) {
15 (0, _assertString.default)(str);
16
17 try {
18 var obj = JSON.parse(str);
19 return !!obj && _typeof(obj) === 'object';
20 } catch (e) {
21 /* ignore */
22 }
23
24 return false;
25}
26
27module.exports = exports.default;
\No newline at end of file