package KiokuDB::Serializer::JSON;
BEGIN {
$KiokuDB::Serializer::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Serializer::JSON::VERSION = '0.57';
use Moose;
use namespace::clean -except => 'meta';
:Backend::Serialize::JSON
);
sub file_extension { "json" }
__PACKAGE__->meta->make_immutable;
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::Serializer::JSON
=head1 VERSION
ve
::JSON;
BEGIN {
$KiokuDB::Backend::Serialize::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Backend::Serialize::JSON::VERSION = '0.57';
use Moose::Role;
# ABSTRACT: Role to serialize entries to JSON
t => 1,
);
has json => (
isa => "Object",
is => "rw",
lazy_build => 1,
handles => [qw(encode decode)],
);
sub _build_json {
my $self = shift;
my $json = JSON->new;
for
$json->$flag if $self->$flag;
}
return $json;
}
sub serialize {
my ( $self, @args ) = @_;
$self->encode( $self->collapse_jspon(@args) );
}
sub deserialize {
my ( $self, $json,
package KiokuDB::TypeMap::Entry::JSON::Scalar;
BEGIN {
$KiokuDB::TypeMap::Entry::JSON::Scalar::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::TypeMap::Entry::JSON::Scalar::VERSION = '0.57';
use Moose;
no w
ke_immutable;
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::TypeMap::Entry::JSON::Scalar
=head1 VERSION
version 0.57
=head1 AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
=h
KiokuDB::Backend::TypeMap::Default::JSON;
BEGIN {
$KiokuDB::Backend::TypeMap::Default::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::Backend::TypeMap::Default::JSON::VERSION = '0.57';
use Moose::Role
FIXME options
KiokuDB::TypeMap::Default::JSON->new
}
__PACKAGE__
__END__
=pod
=encoding UTF-8
=head1 NAME
KiokuDB::Backend::TypeMap::Default::JSON
=head1 VERSION
version 0.57
=head1 AUTHO
package KiokuDB::TypeMap::Default::JSON;
BEGIN {
$KiokuDB::TypeMap::Default::JSON::AUTHORITY = 'cpan:NUFFIN';
}
$KiokuDB::TypeMap::Default::JSON::VERSION = '0.57';
use Moose;
use namespace::clean -
with 'KiokuDB::TypeMap::Default::Canonical' => {
-excludes => [qw(reftype_entries)],
};
has json_boolean_typemap => (
traits => [qw(KiokuDB::TypeMap)],
does => "KiokuDB::Role::
tries,
SCALAR => "KiokuDB::TypeMap::Entry::JSON::Scalar",
REF => "KiokuDB::TypeMap::Entry::JSON::Scalar",
);
}
sub _build_json_boolean_typemap {
my $self = shift;
$sel
ta structure modeling this object/reference. This is a tree, not
a graph, and has no shared data (JSON compliant). All references are symbolic,
using a L<KiokuDB::Reference> object with UIDs as the
ad
rom_stream";
my %types = (
storable => "KiokuDB::Serializer::Storable",
json => "KiokuDB::Serializer::JSON",
yaml => "KiokuDB::Serializer::YAML",
);
coerce( __PACKAGE__,
from
a simplified representation of the object, allowing the data to be
saved in formats as simple as JSON.
References to other objects are converted to symbolic references in the entry,
so objects can b
to pass it in:
KiokuDB->connect( $dsn, typemap => $typemap );
The DSN can also be a valid L<JSON> string taking one of the following forms:
dsn => '["dbi:SQLite:foo",{"schema":"MyApp::DB"}]
a associated with it.
Since the default serializer for the DBI backend is
L<KiokuDB::Serializer::JSON>, we examine the data.
First let's set C<sqlite>'s output mode to C<line>. This is easier to rea
"id":"05A8D61C-6139-4F51-A748-101010CC8B02","root":true}
You'll notice the C<spouse> field has a JSON object with a C<$ref> field inside
it holding the UUID of the target object.
When data is loaded
ouchdb" => "CouchDB",
"mongodb" => "MongoDB",
);
sub _try_json {
my $json = shift;
require JSON;
JSON->new->decode($json);
}
sub dsn_to_backend {
my ( $dsn, @args ) = @_;
i
d_class($class);
return $class->new_from_dsn($rest, @args);
} elsif ( my $args = _try_json($dsn) ) {
my $dsn;
if ( ref $args eq 'ARRAY' ) {
( $dsn, $args ) = @
ry data to JSPON compliant structures
use KiokuDB::Entry;
use KiokuDB::Reference;
use JSON::XS 2.231 ();
use JSON 2.12;
use namespace::clean -except => 'meta';
with qw(KiokuDB::Backend::Serialize::
( $data->root ? ( $self->root_field => JSON::true() ) : () ),
( $data->deleted ? ( $self->deleted_field => JSON::true() ) : () ),
( $data->has_tied ? (
the entry recursively, returning a JSPON compliant data structure
suitable for serialization as a JSON string.
=back
=head1 AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
=head1 COPYRIGHT AND LICE
ad1 VERSION
version 0.57
=head1 DESCRIPTION
This typemap is suitable for serialization using L<JSON>. It stringifies or
otherwise converts data structures into primitive representations.
=head1 AU
apser;
use namespace::clean -except => 'meta';
with qw(
KiokuDB::Backend::TypeMap::Default::JSON
KiokuDB::Backend::Serialize::JSPON::Converter
);
has expander => (
isa => "KiokuDB::Back
<KiokuDB::Entry> and
L<KiokuDB::Reference> objects.
For serialization to JSON strings see L<KiokuDB::Backend::Serialize::JSON>.
=head1 METHODS
=over 4
=item expand_jspon
See L<KiokuDB::Backend::S
ple
L<KiokuDB::Backend::Serialize::Storable> is binary safe, while
L<KiokuDB::Backend::Serialize::JSON> is not).
=head1 AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
=head1 COPYRIGHT AND LICENSE
ckend is
L<KiokuDB::Serializer::JSON>, we examine the data.
=end original
DBIバックエンドのデフォルトのシリアライザーはL<KiokuDB::Serializer::JSON>ですので、
データを
ll notice the C<spouse> field has a JSON object with a C<$ref> field inside
it holding the UUID of the target object.
=end original
C<spouse>フィールドがJSONオブジェクトということ
eserialize);
my %types = (
storable => "KiokuDB::Serializer::Storable",
json => "KiokuDB::Serializer::JSON",
yaml => "KiokuDB::Serializer::YAML",
memory => "KiokuDB::Seriali
nd::Serialize::Storable>,
L<KiokuDB::Backend::Serialize::YAML> and L<KiokuDB::Backend::Serialize::JSON>
for examples.
=head1 REQUIRED METHODS
=over 4
=item serializate $entry
Takes a L<KiokuDB::En
DESCRIPTION
The default typemap is actually defined per backend, in
L<KiokuDB::TypeMap::Default::JSON> and L<KiokuDB::TypeMap::Default::Storable>.
The list of classes handled by both is the same, but
possible with JSON atm", 1 if (
( $self->directory->backend->can("serializer")
and $self->directory->backend->serializer->isa('KiokuDB::Serializer::JSON') )
or $self->directory->backend->does("KiokuDB::Backend::Serialize::JSON")
or $self->directory->backend->does("KiokuDB::Backend::Serialize::JSPON")
);
isa_o