NAME
Config::INI::Serializer - Round-trip INI serializer for nested data
SYNOPSIS
- Data to INI
-
require Config::INI::Serializer; my $ini = Config::INI::Serializer->new; my $data = { an => 'arbitrary', collection => [ 'of', 'data', ], of => { arbitrary => 'depth', }, }; my $ini_text = $ini->serialize($data);
- INI to Data
-
$data = $ini->deserialize($ini_text);
- No functions are exported.
DESCRIPTION
This library is the carved-out INI-file handling from App::Context, namely the essential functions from App:Serializer::Ini and App::Reference.
OH NOES - JET ANOTHR INI MOTULE! - but this one turned out to work better for INI-like nested data serialization where compatibility with other modules is not as important. It is used in the dpath utility.
ACHTUNG! The "round-trip ability" belongs to the data written by the module itself. It does not perfectly keep foreign data structures. Carefully read the CAVEATS
section below.
METHODS
new
Constructor.
serialize
- Signature: $inidata = $serializer->serialize($data);
- Param: $data (ref)
- Return: $inidata (text)
- Sample Usage:
-
$serializer = Config::INI::Serializer->new; $inidata = $serializer->serialize($data);
deserialize
- Signature: $data = $serializer->deserialize($inidata);
- Param: $inidata (text)
- Return: $data (ref)
- Sample Usage:
-
$serializer = Config::INI::Serializer->new; $data = $serializer->deserialize($inidata); print $serializer->dump($data), "\n";
CAVEATS
- It is an extended, probably non-standard variant of INI.
-
It can read most of the other INI formats, but writing is done a bit special to handle nested data.
So using this module is kind of a "one-way ticket to slammertown with no return ticket" aka. vendor lock-in.
- It turns ARRAYs into HASHes.
-
Array indexes are expressed like numbered hash keys:
[list.0] ... [list.1] ... [list.2] ... [list.10]
which, when re-read, actually become hash keys as there is no more distinction after that. Besides losing the array structure this also loses the order of elements.
- It does not handle multiline values correctly.
-
They will written out straight like this
key1 = This will be some funky multi line entry key2 = affe
but on reading you will only get
key1 = This will be
andkey2 = affe
.At least it does not choke on the additional multilines, as long as they don't contain a
=
character.
ACKNOWLEDGEMENTS
I only carved it out into a separate module to provide it as a light-weight dependency.
AUTHORS
Stephen Adkins <spadkins@gmail.com>
Steffen Schwigon <ss5@renormalist.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Stephen Adkins, Steffen Schwigon.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.