Hello Im using HTTParty to call for a remote json file that I need to extract the URL\'s to use in one of my tests.. the json format goes something like:
\"man
Try the following:
#!/usr/bin/env ruby
require 'httparty'
(HOST, ID, VERSION) = ARGV
class MyApi
include HTTParty
format :json
end
response = MyApi.get("http://#{HOST}/v1/dc/manifest/#{ID}/#{VERSION}")
puts response.inspect
The addition of the format :json
tells HTTParty to parse the response as JSON. Then you'll get a hash you can iterate over properly.
Try:
file['manifest']['files'].each do |item|
puts item['url']
end