[Catalyst] Catalyst - any good AJAX tutes?
Peter Corlett
abuse at cabal.org.uk
Fri Mar 6 12:29:30 GMT 2009
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,
}
More information about the Catalyst
mailing list