Skip to content

Instantly share code, notes, and snippets.

@iagooar
Forked from carlcrott/gist:2218175
Created March 29, 2012 11:36
Show Gist options
  • Select an option

  • Save iagooar/2236260 to your computer and use it in GitHub Desktop.

Select an option

Save iagooar/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
@iagooar
Copy link
Author

iagooar commented Mar 29, 2012

[ruby, json]

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