Skip to content

Instantly share code, notes, and snippets.

@matisojka
Forked from carlcrott/gist:2218175
Created March 29, 2012 11:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matisojka/2236260 to your computer and use it in GitHub Desktop.
Save matisojka/2236260 to your computer and use it in GitHub Desktop.
JSON validation method (without monkey patching and with proper error handling)
def valid_json?(value)
JSON.parse value
true
rescue JSON::ParserError, TypeError
false
end
@matisojka
Copy link
Author

[ruby, json]

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