Skip to content

Instantly share code, notes, and snippets.

@jeffjohnson9046
Created August 24, 2014 15:56
Show Gist options
  • Save jeffjohnson9046/044a63f46153ba2b02b7 to your computer and use it in GitHub Desktop.
Save jeffjohnson9046/044a63f46153ba2b02b7 to your computer and use it in GitHub Desktop.
A quick and dirty way to tell if the data received in a response can be parsed as JSON.
def valid_json?(data)
JSON.parse(data)
return true
rescue JSON::ParserError
return false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment