0

I send a get request to a local (separate from app) jetty web server

RestClient.get("ip/command/core/get-version", {})

Then I do a JSON.parse() on the response.

As a result I get

{"revision"=>"r2407", "full_version"=>"2.5 [r2407]", "full_name"=>" [r2407]", "version"=>"2.5"}

What's wrong? How do I turn it into a hash, so I can extract the full_version property?

Euphe
  • 3,531
  • 6
  • 39
  • 69

2 Answers2

1

String returned by service is html encoded. Try decoding it first:

JSON.parse(CGI.unescape_html(response_body))
BroiSatse
  • 44,031
  • 8
  • 61
  • 86
0

Your JSON response looks to be encoded into HTML entities.

If you are using Ruby, try decoding the response using CGI.unescape_html prior to running JSON.parse. Running the result of that method through JSON.parse should give you your hash.

Community
  • 1
  • 1
alxklo
  • 61
  • 3