作者:一个人跳舞飘 | 来源:互联网 | 2024-10-12 21:34
I have tried:
我有尝试:
require 'net/http'
require 'json'
require 'pp'
require 'uri'
url = "http://xyz.com"
resp = Net::HTTP.get_response(URI.parse(url))
buffer = resp.body
result = JSON.parse(buffer)
#result.to_hash
#pp result
puts result
And got the output as:
输出为:
{"id"=>"ABC", "account_id"=>"123", "first_name"=> "PEUS" }
in JSON format but I only need the value of id
to be printed as ABC
.
以JSON格式,但我只需要将id的值打印为ABC。
1 个解决方案