=> 'rw',
isa => Object,
builder => sub {
Bot::Cobalt::Serializer->new(Format => 'JSON')
},
);
{ no warnings 'once'; *Serializer = *serializer; }
## _orig is the original tie().
has
e_key(
sub { $_ .= "\0" }
);
## JSONified values
$self->DB->filter_fetch_value(
sub {
s/\0$//;
$_ = $self->serializer->ref_from_json($_)
unless $self->raw;
}
)
;
$self->DB->filter_store_value(
sub {
$_ = $self->serializer->json_from_ref($_)
unless $self->raw;
$_ .= "\0";
}
);
1
}
sub dbclose {
my ($self) = @_;
unless
ot::Cobalt::Common;
use Bot::Cobalt::Serializer;
our $Serializer = Bot::Cobalt::Serializer->new('JSON');
use HTTP::Request;
use Module::CoreList;
use Try::Tiny;
our $HelpText
= 'try: dist, late
info for $dist ($status)"
);
}
return PLUGIN_EAT_ALL
}
my $json = $response->content;
unless ($json) {
broadcast('message',
$hints->{Context}, $hints->{Channel},
ed for $dist",
);
return PLUGIN_EAT_ALL
}
my $d_hash =
try { $Serializer->thaw($json) }
catch {
broadcast( 'message',
$hints->{Context}, $hints->{Channel},
serialize arbitrary data structures to some
standardized format. Serialization formats such as B<JSON> and B<YAML>
are convenient for "speaking" to other networked applications, sharing
data, or sa
## create a JSON serializer:
my $jsify = Bot::Cobalt::Serializer->new( Format => 'JSON' );
## serialize a perl hash:
my $ref = { Some => { Deep => [ 'Structure' ] } };
my $json = $jsify->fr
use Carp;
use Scalar::Util 'reftype';
## These two must be present anyway:
use YAML::XS ();
use JSON::MaybeXS ();
use Fcntl ':flock';
use Time::HiRes 'sleep';
use Scalar::Util 'blessed';
use Bot:
builder => sub {
+{
YAML => 'YAML::Syck',
YAMLXS => 'YAML::XS',
JSON => 'JSON::MaybeXS',
}
},
);
has yamlxs_from_ref => (
is => 'rw',
lazy => 1,
ire YAML::Syck; YAML::Syck::Load($_[0]) },
);
has json_from_ref => (
is => 'rw',
lazy => 1,
coerce => sub {
my $jsify = JSON::MaybeXS->new(
utf8 => 1, allow_nonref => 1