【发布时间】:2018-12-29 22:03:59
【问题描述】:
尝试使用 JSON.parse 解析 json 字符串时出现意外令牌错误
require "net/http"
require "uri"
url = URI.parse("https://url-goes-here")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
req = Net::HTTP::Get.new(url.request_uri)
req['Accept'] = 'application/json'
res = Net::HTTP.new(url.host, url.port).start do |http|
http.request(req)
end
json = JSON.parse(res)
puts json
【问题讨论】:
-
JSON::ParserError: 765: 'jQuery18307882644047005491_1545806199753({"success":true,"code":0,"results":[{"productId":32817749905,"sellerId": 228928782,"oriMinPrice":"US $363.00","oriMaxPrice":"US $507.10","promotionId":317767132,"startTime":1545638400,"endTime":1546070340,"phase":1,"productTitle":"Top质量...您需要查看整个字符串吗?
-
那不是JSON,更像是JS函数调用。
-
远程站点使用 Struts 框架,添加了 .do 扩展名的 javascript 文件 它是什么类型的数据,如何解析?
-
你想通过上面的代码实现什么是做一些功能,比如抓取。
-
是的,我在刮
标签: ruby-on-rails json