【发布时间】:2023-03-31 04:49:01
【问题描述】:
我想知道第一个射手的名字。这样做的问题是数据位于下面哈希中的数组中的哈希中,然后我需要对其进行测试以查看它是否是目标。
有什么想法吗?
数据:
[
{
"id":1474387,
"date":"2013-11-24 16:00:00",
"competition_id":831975,
"competition":"England Premier League",
"group":"",
"home_id":8344,
"home":"Cardiff City",
"homeshort":"Cardiff",
"homepath":"cardiff-city",
"away_id":10260,
"away":"Manchester United",
"awayshort":"Man Utd",
"awaypath":"manchester-united",
"status":"Finished",
"halftime":[
1,
2
],
"fulltime":[
2,
2
],
"extratime":[
0,
0
],
"penalties":[
0,
0
],
"incidents":[
{
"id":2670186,
"type":"Yellow",
"goaltype":null,
"team_id":10260,
"team":"Manchester United",
"teamshort":"Man Utd",
"teampath":"manchester-united",
"player_id":30829,
"player":"Wayne Rooney",
"playershort":"W. Rooney",
"minute":8
},
{
"id":2670226,
"type":"Goal",
"goaltype":"Regular goal",
"team_id":10260,
"team":"Manchester United",
"teamshort":"Man Utd",
"teampath":"manchester-united",
"player_id":30829,
"player":"Wayne Rooney",
"playershort":"W. Rooney",
"minute":15
},
{
"id":2670320,
"type":"Goal",
"goaltype":"Regular goal",
"team_id":8344,
"team":"Cardiff City",
"teamshort":"Cardiff",
"teampath":"cardiff-city",
"player_id":24157,
"player":"Fraizer Campbell",
"playershort":"F. Campbell",
"minute":33
},
{
"id":2670367,
"type":"Goal",
"goaltype":"Regular goal",
"team_id":10260,
"team":"Manchester United",
"teamshort":"Man Utd",
"teampath":"manchester-united",
"player_id":32569,
"player":"Patrice Evra",
"playershort":"P. Evra",
"minute":45
},
{
"id":2670471,
"type":"Yellow",
"goaltype":null,
"team_id":8344,
"team":"Cardiff City",
"teamshort":"Cardiff",
"teampath":"cardiff-city",
"player_id":176889,
"player":"Steven Caulker",
"playershort":"S. Caulker",
"minute":51
},
{
"id":2670485,
"type":"Yellow",
"goaltype":null,
"team_id":8344,
"team":"Cardiff City",
"teamshort":"Cardiff",
"teampath":"cardiff-city",
"player_id":23806,
"player":"Peter Whittingham",
"playershort":"P. Whittingham",
"minute":55
},
{
"id":2670648,
"type":"Yellow",
"goaltype":null,
"team_id":10260,
"team":"Manchester United",
"teamshort":"Man Utd",
"teampath":"manchester-united",
"player_id":160713,
"player":"Tom Cleverley",
"playershort":"T. Cleverley",
"minute":87
},
{
"id":2670676,
"type":"Goal",
"goaltype":"Regular goal",
"team_id":8344,
"team":"Cardiff City",
"teamshort":"Cardiff",
"teampath":"cardiff-city",
"player_id":197910,
"player":"Bo-Kyung Kim",
"playershort":"BK. Kim",
"minute":90
},
{
"id":2670718,
"type":"Yellow",
"goaltype":null,
"team_id":8344,
"team":"Cardiff City",
"teamshort":"Cardiff",
"teampath":"cardiff-city",
"player_id":159882,
"player":"Kevin Theophile Catherine",
"playershort":"K. Theophile Catherine",
"minute":90
},
{
"id":2670720,
"type":"Yellow",
"goaltype":null,
"team_id":8344,
"team":"Cardiff City",
"teamshort":"Cardiff",
"teampath":"cardiff-city",
"player_id":197910,
"player":"Bo-Kyung Kim",
"playershort":"BK. Kim",
"minute":90
}
]
}
]
【问题讨论】:
-
您需要在我要向您展示的另一个循环中使用 .each 循环,但该代码很难阅读。可以链接控制器吗?
标签: ruby-on-rails ruby json hash