I want to access json string like hash object so that i can access json using key value like temp["anykey"]
. How to convert ruby formatted json string into json object?
I have following json string
temp = '{"accept"=>"*/*", "host"=>"localhost:4567", "version"=>"HTTP/1.1",
"user_agent"=>"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3",
"http_token"=>"375fe428b1d32787864264b830c54b97"}'
Do you know about JSON.parse ?
require 'json'
my_hash = JSON.parse('{"hello": "goodbye"}')
puts my_hash["hello"] => "goodbye"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With