From there How to check whether the given object is object or Array in JSON string i've found useful to compare if JSON object is array or object
if (json instanceof Array) {
// get JSON array
} else {
// get JSON object
}
Problem I have a validator login form and i get messages like:
array('password' => array('isEmpty' => 'Value is required and can't be empty'));
However there is messages like
'Email or password is invalid' , that isn't an array.
Question I need something like this in JavaScript file
if(json hasOnlyOneString)
{
//do something
} else { || } if(json instaceof Array){
// do another stuff
}