Skip to content

Instantly share code, notes, and snippets.

@tracend
Created July 11, 2013 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tracend/5975713 to your computer and use it in GitHub Desktop.
Save tracend/5975713 to your computer and use it in GitHub Desktop.
Underscore Mixin - isJSON : checking if a string is a valid JSON #underscore #js #cc
_.mixin({
isJSON: function(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
});
@rodolfoag
Copy link

_.isJSON(20) should return true or false?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment