【问题标题】:MultiJson::DecodeError: 399: unexpected token atMultiJson::DecodeError: 399: 意外令牌在
【发布时间】:2012-01-26 13:07:35
【问题描述】:

这是我的代码

class Project < ActiveResource::Base
  self.site = "https://xyz.unfuddle.com/api/v1"
  def get_tickets
    ticket_array = []
    Project.all.each do |project|
      project.get(:tickets).each do |ticket|
        #save ticket or something
      end
    end
  end   
end  

project.get(:tickets)中出现错误

lexical error: invalid character inside string.
 16           ": "There is text that shouldn^Zt be there on the DVD/Blu-ray
 17                      (right here) ------^

如何在获取之前检查返回的文本是否只有有效字符?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 json activeresource activesupport


    【解决方案1】:

    无论如何,您都需要获取数据。否则你将无法检查它的有效性。这就是为什么我会添加一个 try-catch-block 并挽救特定错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      • 2014-11-29
      相关资源
      最近更新 更多