josh803316 has asked for the wisdom of the Perl Monks concerning the following question:
The question is, where/how should I change the logic so that a $hash->{'true_false_value'} = JSON::false; is turned into a javascript true_false_value: false instead of true_false_value: "false"use JSON -convert_blessed_universally; use constant SERIALIZER => 'JSON'; *UNIVERSAL::TO_JSON = sub { my $b_obj = B::svref_2object( $_[0] ); return $b_obj->isa('B::HV') ? { %{ $_[0] } } : $b_obj->isa('B::AV') ? [ @{ $_[0] } ] : undef ; }; sub serialize{ my $self = shift; my $params = shift; my $json_obj = JSON->new->allow_nonref; my $serialize = $json_obj->allow_blessed->convert_blessed->encode( + $params ); return $serialize; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: JSON.pm returning "false" instead of false
by ikegami (Patriarch) on Apr 12, 2010 at 21:52 UTC | |
by josh803316 (Beadle) on Apr 12, 2010 at 22:13 UTC | |
by ikegami (Patriarch) on Apr 12, 2010 at 22:31 UTC | |
by josh803316 (Beadle) on Apr 12, 2010 at 22:43 UTC | |
by Anonymous Monk on Apr 13, 2010 at 13:10 UTC | |
by josh803316 (Beadle) on Apr 13, 2010 at 23:43 UTC |