This is an experimental module. The interface may change without notice. Before using it in production, please get in touch with the authors!

Think of Data::Dumper::Limited as supporting a subset of the data structures and features of Data::Dumper. The output is still valid Perl, so you can abuse eval STRING for deserialization. Alternatively, you can choose to use Data::Undump, which is a couple of orders of magnitude faster than eval and does not have the same security implications. Did we mention that this module dumps over 10x faster than Data::Dumper (similar to JSON::XS in our benchmarks)?

The power of this module is very similar to that of generating JSON, except it can dump scalar references, dumps top-level non-references (JSON must be an array or hash ref on the outside), and, again, is valid Perl. Furthermore, this module can optionally dump plain Perl object using bless() function calls. Since this can be unsafe, it needs to be explicitly enabled.

Repeated sub-references are detected, as are cyclic references. Repeated sub-structures are simply serialized multiple times -- they do not round-trip as repeated sub-structures. Since that is at least somewhat dubious, you can set an option that will make DumpLimited throw an exception when encountering repeated sub-structures. Cyclic references currently always cause the module to throw an exception as they are not supported.

This function will return a string that represents the serialization of the first parameter to the function. Optionally, the second parameter can be a hash reference that contains any one of several options, see below.

Boolean, defaults to false. Instead of dying on blessed references, serialize them properly including a call to bless(). Does not include logic for loading thusly referenced modules. That is by design. In the future, this might accept a list of acceptable class names to bless into.

Data::Undump implements the efficient deserialization for this format (minus objects).

JSON::XS contains some excellent code that is very similar to the code in this module for a reason: It solves a similar problem and we included much of the code structure from JSON::XS. Thank you, Marc, for writing great software.