Kong / Kong/unirest-ruby

Response body / parsing to a ruby Hash

Open
#31 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
364
Forks
76
PR merge metrics
No merged PRs in 30d

Description

Hi. When I pull the API data into a Ruby on Rails web app, I think it should be a Hash object, but for some reason, I'm unable to run any Hash methods on it.

Example for Mexico is below. Despite the square brackets, It doesn't seem to be an Array either. I tried running both Hash methods and Array methods on the parsed body, and simply got a Nil Class error: undefined method `[]' for nil:NilClass

Any idea how I might be able to resolve? I would like to get the parsed response body, and then run several Hash methods on it in my rails program.Thanks!

[{ "name"=>"Mexico", "capital"=>"Mexico City", "altSpellings"=>["MX", "Mexicanos", "United Mexican States", "Estados Unidos Mexicanos"], "relevance"=>"1.5", "region"=>"Americas", "subregion"=>"Central America", "translations"=>{"de"=>"Mexiko", "es"=>"México", "fr"=>"Mexique", "ja"=>"メキシコ", "it"=>"Messico"}, "population"=>121740000, "latlng"=>[23.0, -102.0], "demonym"=>"Mexican", "area"=>1964375.0, "gini"=>47.0, "timezones"=>["UTC−08:00", "UTC−07:00", "UTC−06:00"], "borders"=>["BLZ", "GTM", "USA"], "nativeName"=>"México", "callingCodes"=>["52"], "topLevelDomain"=>[".mx"], "alpha2Code"=>"MX", "alpha3Code"=>"MEX", "currencies"=>["MXN"], "languages"=>["es"] }]

Contributor guide

No contributing guide indexed for this repository

Research direction

No source file, test, or calling code is named. Start by tracing how the response body is parsed and exposed by the Ruby client, using the Mexico response as the reproduction case; done means the returned value has a documented Hash or Array shape and supports the expected access methods.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.