Created
April 5, 2012 20:35
-
-
Save celldee/2313898 to your computer and use it in GitHub Desktop.
Handy JSON validation method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
def valid_json?(str) | |
begin | |
JSON.parse(str) | |
return true | |
rescue Exception => e | |
return false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment