MultiJson :: DecodeError 743:发送json数据时将意外令牌放入firefox中的海报添加请求url

时间:2012-04-05 03:55:11

标签: ruby-on-rails json httpwebrequest

我发送下面的json数据作为海报正文的参数

拉​​链=' {"邮编":" 501234""城市名":"水合"" countyname" :" Poweshiek","州名" :" Iowa"}'& Accept = application%2Fjson

我收到错误

'

  MultiJson :: DecodeError`enter code here`

743: unexpected token at 'zip='{"zipcode":"501234","cityname":"hyd","countyname" : "Poweshiek","statename" : "Iowa"}'&Accept=application%2Fjson'

Rails.root: e:/rails/vivadesi

' 下面是日志文件: '开始PUT" /orgs/updatezip.json?id = 4f676eb33e454911a000aea1"对于2012.04.0 07:31:17 +0530的127.0.0.1 解析请求参数时发生错误。 内容:

MultiJson :: DecodeError(743:' zip =' {" zipcode":" 501234"" cityname" :" hyd"," countyname":" Poweshiek"," statename":" Iowa"}' &安培;接受=应用%2Fjson&#39):

渲染的gem / ruby​​ / 1.9.1 / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / templates / rescues / _trace.erb(1.0ms) 渲染的gem / ruby​​ / 1.9.1 / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / templates / rescues / _request_and_response.erb(1.0ms) 在救援/布局(12.0ms)内呈现gem / ruby​​ / 1.9.1 / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / templates / rescues / diagnostics.erb'

1 个答案:

答案 0 :(得分:0)

您是通过发送或获取发送,因为当您尝试将字符串转换为json(格式参数)时出现此错误。

'zip'将是一个想要获取代码的变量 &安培; Accept = application%2Fjson可以作为json中的参数

示例
发送json用于测试

zip='{"zipcode":"501234","cityname":"hyd","countyname" : "Poweshiek","statename" : "Iowa"}'&Accept=application%2Fjson

{"zip":{"zipcode":"501234","cityname":"hyd","countyname" : "Poweshiek","statename" : "Iowa"},"accept":"application%2Fjson"}