++ed by:
KLEE JONASS VOJ

3 PAUSE users
8 non-PAUSE users.

Nicolas Steenlant
and 16 contributors

NAME

Catmandu::Serializer - Base class for all Catmandu Serializers

SYNOPSIS

    package Catmandu::Serializer::Foo;

    use Moo;

    sub serialize {
        my ($self,$data) = @_;
        .. transform the data to a string and return it...
    }

    sub deserialize {
        my ($self,$string) = @_;
        ... transform the string into a perl hash ...
    }

    package MyPackage;

    use Moo;

    with 'Catmandu::Serializer';

    package main;

    my $pkg = MyPackage->new;

    my $string = $pkg->serialize({ foo => 'bar' });
    my $perl   = $pkg->deserialize($string);

    # Using Catmandu::Serializer::Foo 
    my $pkg = MyPackage->new( serialization_format => 'Foo' );

    my $string = $pkg->serialize({ foo => 'bar' });
    my $perl   = $pkg->deserialize($string);
        

DESCRIPTION

This is a convience class to send Perl hashes easily over the wire without having to instantiate a Catmandu::Importer and Catmandu::Exporter which are more suited for processing IO streams.

ATTRIBUTES

serialization_format

The name of the package that serializes data.

serializer

An instance of the package that serializes.

METHODS

serialize($perl)

Serialize a perl data structure into a string.

deserialize($bytes)

Deserialize bytes into a perl data structure.

SEE ALSO

Catmandu::Store::DBI, Catmandu::Serializer::json, Catmandu::Serializer::storabe, Catmandu::Serializer::messagepack