Catmandu::Serializer(3pm)

Catmandu::Serializer3pm

Base class for all catmandu serializers

Usage

    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);

Overview

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.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From libcatmandu-perl 1.2024-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.