I'm learning Ruby.
I have some code that uses the HTTParty library to download some data. The remote server does not correctly define the content-type so the response is not parsed (as JSON) automatically.
The JSON looks something like this:
{"response":{ ............ }}
In the code is the following line:
if resp['response'] == 'response'
In the case that the response is automatically parsed this behaves as expected and { .......... }
from the original JSON would be returned. In the case that it is not parsed it returns the string response
and I cannot figure out why it does that.
Which feature of the HTTParty library causes it to return the string response
?
A different request that results in plain text data returns Nil when trying to access ['response']
.