UNPKG

json-viewer

Version:

Pretty JSON viewer for the terminal

28 lines (21 loc) 620 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.getJsonFromString = undefined; var _console = require('../console'); var getJsonFromString = exports.getJsonFromString = function getJsonFromString() { var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var isString = typeof value === 'string'; if (isString) { try { var json = JSON.parse(value); return json; } catch (parseError) { (0, _console.warn)('Invalid JSON string.'); } } else { (0, _console.warn)('Not a JSON string.'); } return null; };