Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    jsontrypublic

    JSON.parse() in a try:

    exports.parse = function(s) { var o try { o = JSON.parse(s) } catch(e) { o = s } return o }

    installation:

    npm install jsontry

    usage:

    var json = require('jsontry')

    console.log(json.parse(JSON.stringify({ a: 'json', object: true }))) console.log(json.parse('plain text')) console.log({ an: 'object' })

    output:

    { a: 'json', object: true } plain text { an: 'object' }

    Keywords

    none

    install

    npm i jsontry

    Downloadsweekly downloads

    1

    version

    0.0.1

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar