I have a JSON object:
{
"custom_sql_rule":[
{
"custom_sql":[
"Should start with a Select",
"Should not contain ;",
"Some other error"
],
"something_else":[
"Error",
"Should not contain ;",
"Some other error"
]
}
],
"someother_rule":[
{
"sdfsdf":[
"Should start with a Select",
"Should not contain ;",
"Some other error"
],
"sdfsdf":[
"Error",
"Should not contain ;",
"Some other error"
]
}
]
}
I need to append each string error to a div. I quickly whipped this up:
var errorMessages = function(errors, errorsContainer) {
$.each(errors, function(index, value) {
$.each(value, function(i, v) {
$.each(v, function(ia, va) {
$.each(va, function(iab, vab) {
errorsContainer.append($("<div></div>").addClass(index).text(vab));
})
})
})
});
};
It's terrible. Is there a nicer way of handling JSON formed like this? NOTE, I cannot really use keynames.