UNPKG

@youmaole/easy-js

Version:

A lib to make the complex and daily used functions easy to use.

18 lines (17 loc) 436 B
var fnError = require('./error'); module.exports = { toObj: function(str) { try { return JSON.parse(str); } catch (error) { fnError('Your input is not a valid json object string'); } }, toStr: function(obj) { try { return JSON.stringify(obj); } catch (error) { fnError('Your input is not a valid json object'); } } }