我正在尝试在表单上呈现一致的错误消息,但我的错误如下:
OBJECT:
{ "email": [ "can't be blank" ], "password": [ "can't be blank" ] }
预期信息
email can't be blank
password can't be blank
那么,如何将该对象转换为“预期消息”?
答案 0 :(得分:2)
您可以使用for
循环来实现此目的。连接密钥和消息。
var json = { "email": [ "can't be blank" ], "password": [ "can't be blank" ] }
for ( var key in json ) {
console.log( key + " " + json[key] );
}