);
our @JSON_Modules = qw(JSON::XS JSON::PP JSON);
our $JSON_Implementation;
our $JSON;
foreach my $json_module (@JSON_Modules) {
if (eval "require $json_module; 1;") {
$JSON = $json_module->
;
$JSON->indent(0) if $JSON->can('indent');
$JSON->space_before(0) if $JSON->can('space_before');
$JSON->space_after(0) if $JSON->can('space_after');
$JSON->canonical(0) if $JSON->can(
'canonical');
$JSON_Implementation = $json_module;
last if $JSON;
}
}
sub new {
my $class = shift;
my %opt = @_;
if (defined $opt{bins}) {
my $bins = $opt{bins};
croak("Canno
e = lc(shift);
my $hist_dump = $self->{hist}->dump($type);
my $rv = $Math::SimpleHisto::XS::JSON->encode({
%$self,
hist => $hist_dump,
class => ref($self),
histclass => ref($self
lass = shift;
my $type = lc(shift);
my $data = shift;
my $struct = $Math::SimpleHisto::XS::JSON->decode($data);
$class = delete $struct->{class};
my $hclass = delete $struct->{histclass};
_from_dump()> methods
of the C<Math::SimpleHisto::XS> interface by wrapping the histogram dump
in JSON which contains the additional information.
If you always stick to using C<dump()> and C<new_from