with flexible serialization options.
use strict;
use warnings;
use Carp;
use Data::Dumper;
use JSON;
use List::Util qw(pairs);
use Scalar::Util qw(reftype);
use Storable qw(nfreeze);
use YAML ();
or serialization options
our $JSON_PRETTY = 1; # Controls whether JSON output is pretty or compact
our $FORMAT = 'JSON'; # Default serialization format
use overload '""' => \&as_string;
($self) = @_;
return JSON->new->pretty->encode( $self->{data} ) if $FORMAT eq 'JSON' && $JSON_PRETTY;
return JSON->new->encode( $self->{data} ) if $FORMAT eq 'JSON';
return YAML::Dump(