1
page = HTTParty.get("https://api.4chan.org/b/0.json").body
threads = JSON.parse(page)
count = 0
unless threads.nil?
threads['threads'].each do
count = count + 1
end
end
if count > 0
say "You have #{count} new threads."
unless threads['posts'].nil?
threads['posts'].each do |x|
say x['com']
end
end
end
if count == 0
say "You have no new threads."
end
由於某種原因,它說帖子是空的我猜想,但線程從來沒有....我不知道什麼是錯的,它在facebook插件上做同樣的事情,但我昨天工作,現在什麼都沒有。難道我做錯了什麼?JSON解析紅寶石問題
謝謝!這工作 – user2446537