On 6 Mar 2009, at 10:33, Neo [GC] wrote: [...]
To anyone: Be careful when converting perl-datastructures to JSON. I remember having a problem with boolean values, as javascript knows real booleans while perl uses 0 and 1. "use JSON" did have some magic settings to prevent a boolean 0/false to be sent as string "false", which is interpreted as boolean true in javascript. I will ask my collegue, where he has hidden his solution / the cause of the problem (of course, if int 0 and 1 is sent, js casts int 0 to boolean false).
I solved that problem in one of my projects by explicitly putting JSON:: constants into the data structure like so:
$c->stash->{myjsonresponse} = { boolean => $myboolean ? JSON::true : JSON::false, } _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/