1

I send a http request and get a json for response like below:

{"total":"1200.0","used":"35.0","available":1165.0}

now I want deserialize this json and show to user in a table like below:

total : 1200

used : 35

availabele : 1165

I use JSON.parse(response),but I get below error:

no implicit conversion of Net::HTTPOK into String

How can I do this?

mgh
  • 921
  • 3
  • 9
  • 37

2 Answers2

5

Net::HTTP has responses in body. so, Try

JSON.parse response.body
CuriousMind
  • 33,537
  • 28
  • 98
  • 137
0

You have to pass the response.body as the parameters into the JSON.parse method then assign the method to a variable to use elsewhere in your code.

parse_res = JSON.parse(res.body)