NAME

Crypt::OpenToken::Serializer - Serialize payloads for OpenTokens

SYNOPSIS

  use Crypt::OpenToken::Serializer;

  # data to serialize
  my $data = {
      foo => 'bar',
      bar => 'baz',
  };

  # freeze/serialize the data
  my $payload = Crypt::OpenToken::Serializer::freeze(%{$data});

  # thaw/deserialize the data
  my %thawed = Crypt::OpenToken::Serializer::thaw($payload);

DESCRIPTION

This module implements the serialization routine described in the OpenToken specification for generating the payload format.

Highlights:

  • A line-based format in the form of "key = value".

  • Within quoted-strings, both double and single quotes must be escaped by a preceding backslash.

  • Encoded with UTF-8 and is guaranteed to support the transport of multi-byte characters.

  • Key names might not be unique. OpenToken supports multiple values for a key name by simply adding another key-value pair.

  • Key names are case-sensitive. It is RECOMMENDED that all key names be lowercase and use hyphens to separate "words".

METHODS

Crypt::OpenToken::Serializer::thaw($string)

Thaws the given serialized data, returning a hash of data back to the caller.

If the data contained any repeating keys, those are represented in the hash as having an ARRAYREF as a value.

Crypt::OpenToken::Serializer::freeze(%data)

Freezes the given data, returning a serialized string back to the caller.

AUTHOR

Graham TerMarsch (cpan@howlingfrog.com)

COPYRIGHT & LICENSE

Crypt::OpenToken is Copyright (C) 2010, Socialtext, and is released under the Artistic-2.0 license.