STORABLE_freeze
=for Pod::Coverage STORABLE_thaw
=for Pod::Coverage THAW
=for Pod::Coverage TO_JSON
Serialisation by L<CBOR|CBOR::XS>, L<Sereal> and L<Storable::Improved> (or the legacy L<Storable
$self );
}
else
{
CORE::return( $class->new( $str ) );
}
}
sub TO_JSON
{
# JSON does not check that the value is a proper true or false. It stupidly assumes this is a str
STORABLE_freeze
=for Pod::Coverage STORABLE_thaw
=for Pod::Coverage THAW
=for Pod::Coverage TO_JSON
Serialisation by L<CBOR|CBOR::XS>, L<Sereal> and L<Storable> is supported by this package. To th
Nice::Try;
# This is disruptive for everybody. Bad idea.
# use JSON 4.03 qw( -convert_blessed_universally );
use JSON 4.03;
use Scalar::Util ();
# use Storable 3.25 ();
use Sto
sing it as a choice to the user, but defaults to JSON.
# Other possibilities could be cbor, sereal and storable
$self->{_packing_method} = 'json';
$self->SUPER::init( @_ ) || return( $self
) );
}
sub id { return( shift->_set_get_scalar( 'id', @_ ) ); }
sub json { return( shift->_packing_method( 'json' ) ); }
sub key
{
my $self = shift( @_ );
if( @_ )
{
$se
::Util ();
# This is disruptive for everybody. Bad idea.
# use JSON 4.03 qw( -convert_blessed_universally );
use JSON 4.03;
use Module::Generic::Global ':const';
use Storable::Impr
# I leave the feature of using it as a choice to the user, but defaults to JSON
$self->{_packing_method} = 'json';
$self->SUPER::init( @_ ) || return( $self->pass_error );
$self->{own
$self->error( "Error with \$shm->id: $@" ) );
}
return( $rv );
}
sub json { return( shift->_packing_method( 'json' ) ); }
sub key
{
my $self = shift( @_ );
if( @_ )
{
my
}
$h->json({ pretty => 1 });
# Produces
{
"age" : 30,
"email" : "john.doe@example.com",
"first_name" : "John",
"last_name" : "Doe"
}
# Or
$h->json
# Produ
reference containing a copy of the current object data.
=head2 as_json
Returns a json representation of the hash by calling L</json>
=head2 as_string
Return a string version of the hash as produce
lse otherwise.
=head2 json
This returns a L<JSON> representation of the hash. You can provided optionally an hash reference of parameters.
All parameters supported by L</JSON> can be used here.
Fo
ref( $this ) || $this ) )->init( @_ ) );
}
# This class does not convert to an HASH, but the TO_JSON method will convert to a string
sub as_hash { return( $_[0] ); }
sub as_string { return( shift->
se
{
$new = CORE::bless( $hash => $class );
}
CORE::return( $new );
}
sub TO_JSON
{
my $self = CORE::shift( @_ );
CORE::return( '' ) if( !$self->{dt} || !Scalar::Util::ble
DateTime> object to be thawed and frozen and converted to L<JSON> with the respective methods C<STORABLE_freeze>, C<STORABLE_thaw>, C<TO_JSON>
All other method calls not in this API are passed to L<D
set by L</flags> which are used by L</open>.
=item * C<json>
Provided with a value (true or false does not matter), and this will set L<JSON> as the data serialisation mechanism when storing data t
* C<serialiser>
You can provide the serialiser with this option. Possible values are: C<cbor>, C<json>, C<sereal>, C<storable>
=item * C<size>
The size in byte of the shared memory.
This is set on
my $s = $shmem->open || die( $shmem->error );
my $id = $s->id;
=head2 json
When called, this will set L<JSON> as the data serialisation mechanism when storing data to memory or reading dat
length( $clean_field ) );
my( $func_name, $pl );
if( $hash->{ $k }->isa('JSON::PP::Boolean') ||
$hash->{ $k }->isa('Module::Generic::Boolean') )
{
se
{
$new = CORE::bless( $hash => $class );
}
CORE::return( $new );
}
sub TO_JSON
{
my $self = CORE::shift( @_ );
my $ref = { %$self };
CORE::delete( $ref->{_data} );
f( $self->_is_object( $$first_arg ) )
{
if( $self->_is_a( $$first_arg => [qw( JSON::PP::Boolean Module::Generic::Boolean )] ) )
{
$handler = '_set_get_b
se
{
$new = CORE::bless( $hash => $class );
}
CORE::return( $new );
}
sub TO_JSON { return( shift->as_string ); }
sub UNIVERSAL::exception
{
my $class = shift( @_ );
my $
om.example.api",
locale => 'ja-JP',
path => "/home/joe/locale",
use_json => 1,
}) || die( Text::PO::Gettext->error, "\n" );
my $message = $po->gettext( "Somethin
nd call L<perlfunc/"die"> with it.
=head2 TO_JSON
Special method called by L<JSON> to transform this object into a string suitable to be added in a json data.
=head2 trace
Set or get the L<Devel::
> to return a L<Module::Generic::Number> object.
=item * C<object>
For blessed objects (e.g., L<JSON::PP::Boolean>, L<Module::Generic::File>, custom classes), uses the appropriate handler (e.g., L<M
d name patterns (e.g., C<is_active> for boolean, C<url> for URI).
=item * Argument types (e.g., L<JSON::PP::Boolean>, hash, array, scalar).
=item * Value formats (e.g., UUID, IP address, file path).
_JSON
Serialisation is supported for L<CBOR|CBOR::XS>, L<Sereal>, L<Storable::Improved>, and L<Storable>. The module implements C<FREEZE>, C<THAW>, C<STORABLE_freeze>, C<STORABLE_thaw>, and C<TO_JSON
uV`; do echo "sub $sub;"; done
sub AUTOLOAD;
sub DEBUG;
sub DESTROY;
sub FREEZE;
sub THAW;
sub TO_JSON;
sub VERBOSE;
sub as_hash;
sub clear;
sub clear_error;
sub clone;
sub coloured;
sub colour_close;
ub new;
sub new_array;
sub new_datetime;
sub new_file;
sub new_glob;
sub new_hash;
sub new_json;
sub new_json_safe;
sub new_null;
sub new_number;
sub new_scalar;
sub new_tempdir;
sub new_tempfile;
sub
vided to deserialise with $class." ) );
}
}
# NOTE: deserialise with JSON
elsif( $class eq 'JSON' )
{
my @options = qw(
allow_blessed allow_nonref allow_unk