Tuesday, September 3, 2013

Grails hashmap variable in javascript gives different format

Grails hashmap variable in javascript gives different format

In my grails controller:
assert result == [hus:['hus@gmail.com', 'SE', 'on', '9908899876'],
vin:['vin@gmail.com', 'SD', 'on', '7765666543']]
println "result is::"+result
println result.getClass()
[result:result] //passing model to view
which prints :
[hus:[hus@gmail.com, SE, on, 9908899876], vin:[vin@gmail.com, SD, on,
7765666543]]
class java.util.LinkedHashMap
but when i get this hashmap from my view page and access from javascript
$(function(){
alert('${result}');
});
it prints
{
hus=[hus@gmail.com,SE,9902766542],
vin = [vin@gmail.com, SE,887654433]
}
which is not valid object , is not a valid object, (: replaced by =) it
should be
{ hus:[hus@gmail.com,SE,9902766542], vin : [vin@gmail.com, SE,887654433] }
whats wrong here? how do i correct it?

No comments:

Post a Comment