我正在尝试使用API中的数据。以下是我目前使用的代码:
...connection info here
webinars = response.parsed_response["webinars"]
webinars.each do |w|
puts w
end
这给了我一个像:
这样的数组 {"uuid"=>"2342342==", "id"=>285433, "host_id"=>"3423",
"topic"=>"Requirement Changes", "agenda"=>"", "status"=>0,
"option_start_type"=>"video", "option_host_video"=>true, "option_panelist_video"=>true,
"option_audio"=>"both", "option_enforce_login"=>false, "type"=>5,
"start_time"=>"2016-10-24T14:00:00Z", "duration"=>90, "timezone"=>"America/New_York",
"start_url"=>"blah.com",
"join_url"=>"blam.com", "created_at"=>"2016-09-22T13:31:09Z"},
{"uuid"=>"2342343==", "id"=>285434, "host_id"=>"3423",
"topic"=>"Requirement Changes", "agenda"=>"", "status"=>0,
"option_start_type"=>"video", "option_host_video"=>true, "option_panelist_video"=>true,
"option_audio"=>"both", "option_enforce_login"=>false, "type"=>5,
"start_time"=>"2016-10-24T14:00:00Z", "duration"=>90, "timezone"=>"America/New_York",
"start_url"=>"blah.com",
"join_url"=>"blam.com", "created_at"=>"2016-09-22T13:31:09Z"}
我想访问每个网络研讨会中的每个属性,如...
webinars = response.parsed_response["webinars"]
webinars.each do |w|
puts w.id
end
我该如何处理这个,所以我可以调用这样的属性?
答案 0 :(得分:1)
您可以module Doorkeeper
class AccessToken < ActiveRecord::Base
belongs_to :resource_owner, class_name: 'OauthResourceOwner'
include AccessTokenMixin
def as_json(*)
super.except!(:resource_owner_id).merge!(
owner: {
id: resource_owner&.owner_id,
type: resource_owner&.owner_type&.tableize
}
)
end
end
end
代替w["id"]
如果您的地图由w.id
组成,则可以在其上调用{uuid: "2342342==", id: 285433, host_id: "3423"}
。