ruby hash to json
require 'json'
File.open("filename.json", "w") do |f|
f.write(JSON.pretty_generate(my_hash))
end
ruby hash to json
require 'json'
File.open("filename.json", "w") do |f|
f.write(JSON.pretty_generate(my_hash))
end
how to json into hash ruby
response = Faraday.get('https://api.github.com/users/your_username')
r = JSON.parse(response.body, symbolize_names: true)
#OR
JSON.parse(response.body)
#'symbolize_names' turns the keys in this hash into symbols, not required
#JSON.parse is what turns the JSON object into a hash
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us