{
    "mode": "perldoc",
    "parameter": "Data::Serializer",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Data%3A%3ASerializer/json",
    "generated": "2026-06-09T15:00:09Z",
    "synopsis": "use Data::Serializer;\n$obj = Data::Serializer->new();\n$obj = Data::Serializer->new(\nserializer => 'Storable',\ndigester   => 'MD5',\ncipher     => 'DES',\nsecret     => 'my secret',\ncompress   => 1,\n);\n$serialized = $obj->serialize({a => [1,2,3],b => 5});\n$deserialized = $obj->deserialize($serialized);\nprint \"$deserialized->{b}\\n\";",
    "sections": {
        "NAME": {
            "content": "Data::Serializer:: - Modules that serialize data structures\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Data::Serializer;\n\n$obj = Data::Serializer->new();\n\n$obj = Data::Serializer->new(\nserializer => 'Storable',\ndigester   => 'MD5',\ncipher     => 'DES',\nsecret     => 'my secret',\ncompress   => 1,\n);\n\n$serialized = $obj->serialize({a => [1,2,3],b => 5});\n$deserialized = $obj->deserialize($serialized);\nprint \"$deserialized->{b}\\n\";\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Provides a unified interface to the various serializing modules currently available. Adds the\nfunctionality of both compression and encryption.\n\nBy default Data::Serializer(3) adds minor metadata and encodes serialized data structures in\nit's own format. If you are looking for a simple unified pass through interface to the\nunderlying serializers then look into Data::Serializer::Raw(3) that comes bundled with\nData::Serializer(3).\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Please see Data::Serializer::Cookbook(3)\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new - constructor\n$obj = Data::Serializer->new();\n\n\n$obj = Data::Serializer->new(\nserializer => 'Data::Dumper',\ndigester   => 'SHA-256',\ncipher     => 'Blowfish',\nsecret     => undef,\nportable   => '1',\ncompress   => '0',\nserializertoken => '1',\noptions  => {},\n);\n\nnew is the constructor object for Data::Serializer(3) objects.\n\n*   The default *serializer* is \"Data::Dumper\"\n\n*   The default *digester* is \"SHA-256\"\n\n*   The default *cipher* is \"Blowfish\"\n\n*   The default *secret* is \"undef\"\n\n*   The default *portable* is 1\n\n*   The default *encoding* is \"hex\"\n\n*   The default *compress* is 0\n\n*   The default *compressor* is \"Compress::Zlib\"\n\n*   The default *serializertoken* is 1\n\n*   The default *options* is \"{}\" (pass nothing on to serializer)\n\nserialize - serialize reference\n$serialized = $obj->serialize({a => [1,2,3],b => 5});\n\nSerializes the reference specified.\n\nWill compress if compress is a true value.\n\nWill encrypt if secret is defined.\n\ndeserialize - deserialize reference\n$deserialized = $obj->deserialize($serialized);\n\nReverses the process of serialization and returns a copy of the original serialized\nreference.\n\nfreeze - synonym for serialize\n$serialized = $obj->freeze({a => [1,2,3],b => 5});\n\nthaw - synonym for deserialize\n$deserialized = $obj->thaw($serialized);\n\nrawserialize - serialize reference in raw form\n$serialized = $obj->rawserialize({a => [1,2,3],b => 5});\n\nThis is a straight pass through to the underlying serializer, nothing else is done. (no\nencoding, encryption, compression, etc)\n\nIf you desire this functionality you should look at Data::Serializer::Raw(3) instead, it is\nfaster and leaner.\n\nrawdeserialize - deserialize reference in raw form\n$deserialized = $obj->rawdeserialize($serialized);\n\nThis is a straight pass through to the underlying serializer, nothing else is done. (no\nencoding, encryption, compression, etc)\n\nIf you desire this functionality you should look at Data::Serializer::Raw(3) instead, it is\nfaster and leaner.\n\nsecret - specify secret for use with encryption\n$obj->secret('mysecret');\n\nChanges setting of secret for the Data::Serializer(3) object. Can also be set in the\nconstructor. If specified than the object will utilize encryption.\n\nportable - encodes/decodes serialized data\nUses encoding method to ascii armor serialized data\n\nAids in the portability of serialized data.\n\ncompress - compression of data\nCompresses serialized data. Default is not to use it. Will compress if set to a true value\n$obj->compress(1);\n\nraw - all calls to serializer and deserializer will automatically use raw mode\nSetting this to a true value will force serializer and deserializer to work in raw mode (see\nrawserializer and rawdeserializer). The default is for this to be off.\n\nIf you desire this functionality you should look at Data::Serializer::Raw(3) instead, it is\nfaster and leaner.\n\nserializer - change the serializer\nCurrently supports the following serializers:\n\nBencode(3)\nConvert::Bencode(3)\nConvert::BencodeXS(3)\nConfig::General(3)\nData::Denter(3)\nData::Dumper(3)\nData::Taxi(3)\nFreezeThaw(3)\nJSON(3)\nJSON::Syck(3)\nPHP::Serialization(3)\nStorable(3)\nXML::Dumper(3)\nXML::Simple(3)\nYAML(3)\nYAML::Syck(3)\n\nDefault is to use Data::Dumper.\n\nEach serializer has its own caveat's about usage especially when dealing with cyclical data\nstructures or CODE references. Please see the appropriate documentation in those modules for\nfurther information.\n\ncipher - change the cipher method\nUtilizes Crypt::CBC(3) and can support any cipher method that it supports.\n\ndigester - change digesting method\nUses Digest(3) so can support any digesting method that it supports. Digesting function is\nused internally by the encryption routine as part of data verification.\n\ncompressor - changes compresing module\nCurrently Compress::Zlib(3) and Compress::PPMd(3) are the only options\n\nencoding - change encoding method\nEncodes data structure in ascii friendly manner. Currently the only valid options are hex,\nor b64.\n\nThe b64 option uses Base64 encoding provided by MIME::Base64(3), but strips out newlines.\n\nserializertoken - add usage hint to data\nData::Serializer(3) prepends a token that identifies what was used to process its data. This\nis used internally to allow runtime determination of how to extract serialized data.\nDisabling this feature is not recommended. (Use Data::Serializer::Raw(3) instead).\n\noptions - pass options through to underlying serializer\nCurrently is only supported by Config::General(3), and XML::Dumper(3).\n\nmy $obj = Data::Serializer->new(serializer => 'Config::General',\noptions    => {\n-LowerCaseNames       => 1,\n-UseApacheInclude     => 1,\n-MergeDuplicateBlocks => 1,\n-AutoTrue             => 1,\n-InterPolateVars      => 1\n},\n) or die \"$!\\n\";\n\nor\n\nmy $obj = Data::Serializer->new(serializer => 'XML::Dumper',\noptions    => { dtd => 1, }\n) or die \"$!\\n\";\n\nstore - serialize data and write it to a file (or file handle)\n$obj->store({a => [1,2,3],b => 5},$file, [$mode, $perm]);\n\nor\n\n$obj->store({a => [1,2,3],b => 5},$fh);\n\nSerializes the reference specified using the serialize method and writes it out to the\nspecified file or filehandle.\n\nIf a file path is specified you may specify an optional mode and permission as the next two\narguments. See IO::File for examples.\n\nTrips an exception if it is unable to write to the specified file.\n\nretrieve - read data from file (or file handle) and return it after deserialization\nmy $ref = $obj->retrieve($file);\n\nor\n\nmy $ref = $obj->retrieve($fh);\n\nReads first line of supplied file or filehandle and returns it deserialized.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Neil Neely <neil@neely.cx>.\n\nFeature requests are certainly welcome.\n\nhttp://neil-neely.blogspot.com/\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report all bugs here:\n\nhttp://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer\n",
            "subsections": []
        },
        "TODO": {
            "content": "Extend the persistent framework. Perhaps Persistent::Base(3) framework would be useful to\nexplore further. Volunteers for putting this together would be welcome.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (c) 2001-2020 Neil Neely. All rights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may\nhave available.\n\nSee http://www.perl.com/language/misc/Artistic.html\n",
            "subsections": []
        },
        "ACKNOWLEDGEMENTS": {
            "content": "Gurusamy Sarathy and Raphael Manfredi for writing MLDBM(3), the module which inspired the\ncreation of Data::Serializer(3).\n\nAnd thanks to all of you who have provided the feedback that has improved this module over the\nyears.\n\nIn particular I'd like to thank Florian Helmberger, for the numerous suggestions and bug fixes.\n",
            "subsections": []
        },
        "DEDICATION": {
            "content": "This module is dedicated to my beautiful wife Erica.\n",
            "subsections": []
        },
        "REPOSITORY": {
            "content": "<http://github.com/neilneely/Data-Serializer/>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Bencode(3)\nConvert::Bencode(3)\nConvert::BencodeXS(3)\nConfig::General(3)\nData::Denter(3)\nData::Dumper(3)\nData::Taxi(3)\nFreezeThaw(3)\nJSON(3)\nJSON::Syck(3)\nPHP::Serialization(3)\nStorable(3)\nXML::Dumper(3)\nXML::Simple(3)\nYAML(3)\nYAML::Syck(3)\nCompress::Zlib(3)\nCompress::PPMd(3)\nDigest(3)\nDigest::SHA(3)\nCrypt::CBC(3)\nMIME::Base64(3)\nIO::File(3)\nData::Serializer::Config::Wrest(3) - adds supports for Config::Wrest(3)\n",
            "subsections": []
        }
    },
    "summary": "Data::Serializer:: - Modules that serialize data structures",
    "flags": [],
    "examples": [
        "Please see Data::Serializer::Cookbook(3)"
    ],
    "see_also": [
        {
            "name": "Bencode",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Bencode/3/json"
        },
        {
            "name": "Bencode",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Bencode/3/json"
        },
        {
            "name": "BencodeXS",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/BencodeXS/3/json"
        },
        {
            "name": "General",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/General/3/json"
        },
        {
            "name": "Denter",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Denter/3/json"
        },
        {
            "name": "Dumper",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Dumper/3/json"
        },
        {
            "name": "Taxi",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Taxi/3/json"
        },
        {
            "name": "FreezeThaw",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/FreezeThaw/3/json"
        },
        {
            "name": "JSON",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/JSON/3/json"
        },
        {
            "name": "Syck",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Syck/3/json"
        },
        {
            "name": "Serialization",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Serialization/3/json"
        },
        {
            "name": "Storable",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Storable/3/json"
        },
        {
            "name": "Dumper",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Dumper/3/json"
        },
        {
            "name": "Simple",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Simple/3/json"
        },
        {
            "name": "YAML",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/YAML/3/json"
        },
        {
            "name": "Syck",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Syck/3/json"
        },
        {
            "name": "Zlib",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Zlib/3/json"
        },
        {
            "name": "PPMd",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/PPMd/3/json"
        },
        {
            "name": "Digest",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Digest/3/json"
        },
        {
            "name": "SHA",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/SHA/3/json"
        },
        {
            "name": "CBC",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/CBC/3/json"
        },
        {
            "name": "Base64",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Base64/3/json"
        },
        {
            "name": "File",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/File/3/json"
        },
        {
            "name": "Wrest",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Wrest/3/json"
        },
        {
            "name": "Wrest",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/Wrest/3/json"
        }
    ]
}