[ { "venues" => [ { "city" => "Madrid", "address" => -6ren">
gpt4 book ai didi

ruby - 如何从此四方哈希中获取键 => 值?

转载 作者:太空宇宙 更新时间:2023-11-03 16:11:01 25 4
gpt4 key购买 nike

这是它的样子:

{
"groups" => [
{ "venues" => [
{ "city" => "Madrid",
"address" => "Camino de Perales, s/n",
"name" => "Caja Mágica",
"stats" => {"herenow"=>"0"},
"geolong" => -3.6894333,
"primarycategory" => {
"iconurl" => "http://foursquare.com/img/categories/arts_entertainment/stadium.png",
"fullpathname" => "Arts & Entertainment:Stadium",
"nodename" => "Stadium",
"id" => 78989 },
"geolat" => 40.375045,
"id" => 2492239,
"distance" => 0,
"state" => "Spain" }],
"type" => "Matching Places"}]
}

又大又丑。。。我只想把id抢出来。我该怎么做呢?

最佳答案

h = { "组"=> ......... }

这两个id是:

h["groups"][0]["venues"][0]["primarycategory"]["id"]
h["groups"][0]["venues"][0]["id"]

关于ruby - 如何从此四方哈希中获取键 => 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3636912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com