简体   繁体   English

Ruby on Rails JSON.parse“意外令牌”错误

[英]Ruby on Rails JSON.parse “unexpected token” error

I am trying to parse JSON data in my Rails 4 application with JSON.parse . 我正在尝试使用JSON.parse解析Rails 4应用程序中的JSON数据。 I keep getting this error: 我不断收到此错误:

757: unexpected token at '<?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>BB0CDD4F68DBE9C0</RequestId><HostId>SwLqpcx7wpspbYzXONm1XGRG46dGHxnDroplppsxqtU4v/iVwEGOvpRWpBNR+LMPduTldva/5Nk=</HostId></Error>'

在此处输入图片说明

Looks like error response is not returned as JSON. 看起来错误响应未作为JSON返回。 You could do something like: 您可以执行以下操作:

def reviews
  JSON.parse(reviews_json)['Reviews']
rescue JSON::ParserError
  []
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails JSON.parse“意外令牌”错误 - Rails JSON.parse "unexpected token" error Ruby JSON.parse提供意外的令牌错误 - Ruby JSON.parse gives unexpected token error Rspec Rails 测试错误:失败/错误:JSON.parse(response.body) &amp;&amp; JSON::ParserError: 78'4: - Rspec Rails Test Error :Failure/Error: JSON.parse(response.body) && JSON::ParserError: 784: unexpected token at ' ' 如何将JSON响应返回到Rails应用json.parse意外令牌 - How to get json response back into rails app json.parse unexpected token 无法使用功能JSON.parse解析Rails中的ruby中的JSON - Not able to parse JSON in ruby on rails using function JSON.parse Rails XHR 导致错误:SyntaxError: JSON.parse: JSON 数据的第 1 行第 1 列出现意外字符 - Rails XHR causes error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data Rails:语法错误:JSON.parse:JSON数据的第2行第1列出现意外字符 - Rails: Syntax error: JSON.parse: unexpected character at line 2 column 1 of the JSON data Ruby / Rails - JSON.parse / JSON.decode问题 - Ruby/Rails - issues with JSON.parse/JSON.decode JSON请求的Rails服务器意外令牌解析错误 - Rails server unexpected token parse error for JSON request jquery .ajax对rails服务器上的ruby发出请求,在客户端上发出JSON.parse错误 - jquery .ajax post request to a ruby on rails server gives a JSON.parse error on the client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM