NAME
JSON::Dumper::Compact - JSON processing with Data::Dumper::Compact aesthetics
SYNOPSIS
use JSON::Dumper::Compact 'jdc';
my $json = jdc($data);
DESCRIPTION
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:
{ "__bless__": [
"The::Class",
{ "the": "object },
] }
METHODS
In addition to the Data::Dumper::Compact methods, we provide:
encode
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.
decode
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.
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
Copyright (c) 2019 the "AUTHOR" in Data::Dumper::Compact and "CONTRIBUTORS" in Data::Dumper::Compact.
LICENSE
This library is free software and may be distributed under the same terms as perl itself. See https://dev.perl.org/licenses/.