niclake Posted February 9, 2023 Posted February 9, 2023 Trying to create a little workflow as practice. Querying an API, parsing the response, and then (trying to) copying the result to my clipboard. Here's my script: require 'json' require 'uri' require 'net/http' uri = URI("https://baconipsum.com/api/?type=all-meat&start-with-lorem=1¶s=5") res = Net::HTTP.get_response(uri) value = "" JSON.parse(res.body).each do |i| value += i + " " end puts({ items: [value] }.to_json) I get the data back just fine, and it's being returned as an appropriate json hash, but the Alfred window will just sit open and not accept me hitting Enter to copy it to my clipboard.
vitor Posted February 9, 2023 Posted February 9, 2023 JSON is structured data, you have to follow the correct structure for it to be interpreted.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now