Answers for "parse json to hash rails"

0

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
Posted by: Guest on October-06-2020
-1

JSON to Ruby Hash Parser

require 'json'

my_hash = JSON.parse('{"hello": "goodbye"}')
puts my_hash["hello"] => "goodbye"
Posted by: Guest on November-05-2021

Browse Popular Code Answers by Language