pod
=head3 C<to_json($data)>
Returns the JSON representation of C<$data> (arbitrary
datastructure -- but not objects). See http://www.json.org/ or
http://en.wikipedia.org/wiki/JSON for details. In
to_json {
my $self = shift;
my $data = shift;
return 'null' unless defined $data;
my $type = reftype($data);
unless (defined($type)) {
return $self->_escape_json_str
n(',', map { $self->to_json($_) } @$data) . ']';
}
elsif ($type eq 'HASH') {
my @keys = sort keys %$data;
return '{' . join(',', map { $self->_escape_json_str($_) . ':'