JSON::Dumper::Compact - JSON processing with Data::Dumper::Compact aesthetics
use JSON::Dumper::Compact 'jdc'; my $json = jdc($data);
JSON::Dumper::Compact is a subclass of Data::Dumper::Compact that turns arrayrefs and hashrefs intead into JSON.
Blessed references without a TO_JSON method are rendered as:
TO_JSON
{ "__bless__": [ "The::Class", { "the": "object" }, ] }
In addition to the Data::Dumper::Compact methods, we provide:
JSON::Dumper::Compact->encode($data, \%opts?); $jdc->encode($data, \%opts?);
Operates identically to "dump" in Data::Dumper::Compact but named to be less confusing to code expecting a JSON object.
JSON::Dumper::Compact->decode($string, \%opts?); $jdc->decode($string, \%opts);
Runs the supplied string through an JSON::MaybeXS decode with options set to be able to reliably reparse what we can currently format - notably setting relaxed to allow for trailing commas and using filter_json_single_key_object to re-inflate blessed objects.
decode
relaxed
filter_json_single_key_object
Note that using this method on untrusted data is a security risk. Don't use debugging specific code on untrusted data, use JSON::MaybeXS or Mojo::JSON directly.
DO NOT USE THIS METHOD ON UNTRUSTED DATA IT WAS NOT DESIGNED TO BE SECURE.
Copyright (c) 2019 the "AUTHOR" in Data::Dumper::Compact and "CONTRIBUTORS" in Data::Dumper::Compact as listed in Data::Dumper::Compact.
This library is free software and may be distributed under the same terms as perl itself. See https://dev.perl.org/licenses/.
To install Data::Dumper::Compact, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Dumper::Compact
CPAN shell
perl -MCPAN -e shell install Data::Dumper::Compact
For more information on module installation, please visit the detailed CPAN module installation guide.