Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JSON.parse() in a try
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
LICENCE
README
jsontry.js
package.json
test.js

README

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' }
Something went wrong with that request. Please try again.