解析以下JSON数据有什么问题
'{
{"errors":
{"firstname":"is too short"}
},
{"account":
{"firstname":"Test"}
}
}'
为哪一个得到这个错误?
JSON::ParserError in AccountsController#home
706: unexpected token at ... # the code above
?
在我的 AccountsController 中
JSON.parse(json_data)["errors"]
最佳答案
你不应该封装属性errors和account。它应该看起来像这样:
'{
"errors":{"firstname":"is too short"},
"account":{"firstname":"Test"}
}'
关于ruby-on-rails - 解析 JSON 数据时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5211034/