Exporter;
use base "JSON::PP";
use overload;
use Carp ();
use B ();
use Class::C3;
$JavaScript::Dumper::VERSION = '0.011';
@JavaScript::Dumper::EXPORT = qw(js_dumper);
my $JSON; # cache
sub js_d
umper ($) { # encode
($JSON ||= __PACKAGE__->new)->encode(@_);
}
sub value_to_json {
my ($self, $value) = @_;
my $type = ref($value);
if (!defined $value) {
return "null";
} elsif($type eq
lean" => true, "call": function}]";
=head1 DESCRIPTION
This module uses L<JSON::PP> as base and overrides C<value_to_json> to accept SCALAR-refs to be returned without quotes.
=head1 FUNCTIONS
=o