Answer the question
In order to leave comments, you need to log in
How to find out what was received: JSON or not?
There is a link to JSON. Information on it is parsed in the RoR application.
Sometimes on a remote server, instead of JSON, a 503 error appears, stating that the server is currently unavailable.
url = 'this url'
uri = URI(url)
response = Net::HTTP.get(uri)
data = JSON.parse(response)
Answer the question
In order to leave comments, you need to log in
Yes, in general, just a status check is intended to verify information.
usually it is written, if the status is 200, then we start parsing JSON.
def valid_json?(json)
begin
JSON.parse(json)
return true
rescue JSON::ParserError => e
return false
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question