In Ruby, is there a way to check if a string is valid json before trying to parse it?
For example getting some information from some other urls, sometimes it returns json, sometimes it could return a garbage which is not a valid response.
My code:
def get_parsed_response(response)
parsed_response = JSON.parse(response)
end