我有一个在 Ruby 1.9.3 上运行的 Rails 3.2 应用程序,它返回存储在 MongoDB 数据库中的 JSON 数据。数据似乎正确存储在 mongo 中,例如(查看 name 属性):
{ "_id" : ObjectId("4f986cbe4c8086fdc9000002"), "created_at" : ISODate("2012-04-25T21:31:45.474Z"), "updated_at" : ISODate("2012-04-26T22:07:23.901Z"), "creator_id" : ObjectId("4f6b4d3c4c80864381000001"), "updater_id" : null, "name" : "Trädgår'n", "sort" : "tradgarn", "address" : "Nya Allén 11", "coordinates" : [ 11.9764791, 57.7045625 ], "phone" : "46031102080", "url" : "http://www.profilrestauranger.se/tradgarn/", "user_ids" : [ ] }
但是当我发出一个返回这条记录的请求时,我得到了类似的东西(现在看看 name 属性):
{"address":"Nya All\u00e9n 11","coordinates":[11.9764791,57.7045625],"created_at":"2012-04-25T23:31:45+02:00","id":"4f986cbe4c8086fdc9000002","name":"Tr\u00e4dg\u00e5r'n","phone":"46031102080","sort":"tradgarn","updated_at":"2012-04-27T00:07:23+02:00","url":"http://www.profilrestauranger.se/tradgarn/"}
任何感兴趣的人的响应标头:
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Thu, 26 Apr 2012 22:41:13 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 909
Connection: keep-alive
Status: 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers: *,x-requested-with
X-UA-Compatible: IE=Edge
ETag: "d2a95f06bec10d8087c3188280292d3c"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: fdd042568195df279e59affe45bdcd37
X-Runtime: 0.037134
我似乎无法弄清楚编码为什么或在哪里弄乱了?是什么赋予了?帮助?:)