Rails 请教问题:rails 接收 json 数据错误

oldcwj · May 22, 2012 · Last by oldcwj replied at May 22, 2012 · 3703 hits

我用 Android 的 httpclient 向 rails 发送 post 请求,在 console 中得到是: Parameters: {"_json"=>"totake=aaa&togive=bbb"}

不明白为什么不是{"_json"=>{"tokake"=>"aaa", "togive"=>"bbb"}}这种格式

Android 代码如下: HttpPost postRequest = new HttpPost(r.url); postRequest.setHeader("Accept", "application/json"); postRequest.setHeader("Content-Type","application/json"); postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));

不知道有人遇到过这样的问题没有?谢谢!

应该是 java 代码的问题

应该是 Android 发送 JSON 格式错误,和 Rails 没关系。

这种情况只能手工 hack 了

是我的 java 代码有问题!谢谢各位了

You need to Sign in before reply, if you don't have an account, please Sign up first.