【发布时间】:2014-03-03 09:09:05
【问题描述】:
我目前有一个公开的 Google 日历,我正在使用 Google's API 成功提取 JSON 数据。
我正在使用 HTTParty 将 JSON 转换为 ruby 对象。
response = HTTParty.get('http://www.google.com/calendar/feeds/colorado.edu_mdpltf14q21hhg50qb3e139fjg@group.calendar.google.com/public/full?alt=json&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true')
我想检索许多标题、事件名称、开始时间、结束时间等。我可以用类似的命令得到这些
response["feed"]["title"["$t"]
日历的标题,以及
response["feed"]["entry"][0]["title"]["$t"]
事件的标题。
我的问题有两个。一,有没有更简单的方法来提取这些数据?二、如何拉取多个事件信息?我试过了:
response.each do |x| response["feed"]["title"]["$t"]
但这会吐出一个字符串没有隐式转换为整数的错误。
【问题讨论】:
标签: ruby json calendar google-calendar-api