App::Serializer::Xml - Interface for serialization and deserialization
use App; $context = App->context(); $serializer = $context->service("Serializer"); # or ... $serializer = $context->serializer(); $data = { an => 'arbitrary', collection => [ 'of', 'data', ], of => { arbitrary => 'depth', }, }; $xml = $serializer->serialize($data); $data = $serializer->deserialize($xml); print $serializer->dump($data), "\n";
A Serializer allows you to serialize a structure of data of arbitrary depth to a scalar and deserialize it back to the structure.
The Xml serializer uses non-validated XML as the serialized form of the data. It uses the XML::Simple class to perform the deserialization and serialization.
* Throws: App::Exception::Serializer * Since: 0.01
The class is entirely made up of static (class) methods. However, they are each intended to be called as methods on the instance itself.
The constructor is inherited from App::Service.
App::Service
* Signature: $xml = $serializer->serialize($data); * Param: $data ref * Return: $xml text * Throws: App::Exception::Serializer * Since: 0.01 Sample Usage: $context = App->context(); $serializer = $context->service("Serializer"); # or ... $serializer = $context->serializer(); $data = { an => 'arbitrary', collection => [ 'of', 'data', ], of => { arbitrary => 'depth', }, }; $xml = $serializer->serialize($data);
* Signature: $data = $serializer->deserialize($xml); * Signature: $data = App::Serializer->deserialize($xml); * Param: $data ref * Return: $xml text * Throws: App::Exception::Serializer * Since: 0.01 Sample Usage: $context = App->context(); $serializer = $context->service("Serializer"); # or ... $serializer = $context->serializer(); $data = $serializer->deserialize($xml); print $serializer->dump($data), "\n";
* Signature: $serialized_content_type = $service->serialized_content_type(); * Param: void * Return: $serialized_content_type string * Throws: App::Exception * Since: 0.01 Sample Usage: $serialized_content_type = $service->serialized_content_type();
This method is inherited from App::Serializer.
App::Serializer
* Author: Stephen Adkins <spadkins@gmail.com> * License: This is free software. It is licensed under the same terms as Perl itself.
App::Context, App::Service
App::Context
To install App::Context, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Context
CPAN shell
perl -MCPAN -e shell install App::Context
For more information on module installation, please visit the detailed CPAN module installation guide.