Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@rodolfoag rodolfoag commented Jul 27, 2015

_.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