In java i have hashmap
Map<String , List<Employee>> employeeMap = new HashMap<String , List<Employee>> ();
employeeMap.put(1, new Employee());
........
I am adding it in request attribute
Now in javascript i need to loop over over map, to get keys and values
Here what i tried
Approach 1 :-
var empMap = '${employeeMap}';
//here is the example value of map in javascript which i see while debugging
//var empMap = {emp1_100=[com.Employee@5b7b4bc5], emp2...
for (var key in empMap) {
alert(key + ': ' + empMap[key]);
}
But getting syntax error
SyntaxError: missing : after property id
Approach 2 :- with jquery
var jsonMap = $.stringify(empMap);
$.each( jsonMap, function( key, value ) {
alert( key + ": " + value );
});
But its not working either. It print some characters.
I am not sure what i am missing here ?