[WP/1438] JSON 을 파싱하는 방법
require "net/http" | |
require "json" | |
uri = URI("https://api.spotify.com/v1/search?type=artist&q=tycho") | |
# get_response 를 이용하는 방법 | |
response = Net::HTTP.get_response(uri) | |
puts response # <Net::HTTPOK:0x007fbe2b054880> | |
puts response.body # String | |
puts JSON.parse(response.body) # Hash | |
# get 을 이용하는 방법 | |
# response = Net::HTTP.get(uri) | |
# puts JSON.parse(response) # Hash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment