开发者

Rails JSON Deserialization Invalid

Rails JSON deserialization seems to be creating invalid JSON when serializing errors. For example, the followi开发者_StackOverflowng snippet appears correct as a hash but incorrect as json:

@model.errors
# { message: ["it too short (minimum is 2 characters)", "contains inappropriate content"] }

@model.errors.to_json
# {
#  message: "is too short (minimum is 2 characters)",
#  message: "contains inapproriate content",
# }

Am I incorrect in understanding that keys must be unique? Thanks.


Problem with an outdated version of Rails (3.0.3). Updated to 3.0.9 and everything worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜