App-ppgrep
view release on metacpan or search on metacpan
script/_ppgrep view on Meta::CPAN
#This software is copyright (c) 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar@cpan.org.
#
#This is free software; you can redistribute it and/or modify it under
#the same terms as the Perl 5 programming language system itself.
#
#=cut
### Data/Clean/FromJSON.pm ###
#package Data::Clean::FromJSON;
#
#our $DATE = '2019-11-26'; # DATE
#our $VERSION = '0.395'; # VERSION
#
#use 5.010001;
#use strict;
#use warnings;
#
#use parent qw(Data::Clean);
#use vars qw($creating_singleton);
#
#sub new {
# my ($class, %opts) = @_;
# if (!%opts && !$creating_singleton) {
# warn "You are creating a new ".__PACKAGE__." object without customizing options. ".
# "You probably want to call get_cleanser() yet to get a singleton instead?";
# }
#
# $opts{"JSON::PP::Boolean"} //= ['deref_scalar_one_or_zero'];
#
# $class->SUPER::new(%opts);
#}
#
#sub get_cleanser {
# my $class = shift;
# local $creating_singleton = 1;
# state $singleton = $class->new;
# $singleton;
#}
#
#1;
## ABSTRACT: Clean data from JSON decoder
#
#__END__
#
#=pod
#
#=encoding UTF-8
#
#=head1 NAME
#
#Data::Clean::FromJSON - Clean data from JSON decoder
#
#=head1 VERSION
#
#This document describes version 0.395 of Data::Clean::FromJSON (from Perl distribution Data-Clean-ForJSON), released on 2019-11-26.
#
#=head1 SYNOPSIS
#
# use Data::Clean::FromJSON;
# use JSON;
# my $cleanser = Data::Clean::FromJSON->get_cleanser;
# my $data = JSON->new->decode('[true]'); # -> [bless(do{\(my $o=1)},"JSON::XS::Boolean")]
# my $cleaned = $cleanser->clean_in_place($data); # -> [1]
#
#=head1 DESCRIPTION
#
#This class can "clean" data that comes from a JSON encoder. Currently what it
#does is:
#
#=over
#
#=item * Convert boolean objects to simple Perl values
#
#=back
#
#=head1 METHODS
#
#=head2 CLASS->get_cleanser => $obj
#
#Return a singleton instance, with default options. Use C<new()> if you want to
#customize options.
#
#=head2 CLASS->new() => $obj
#
#=head2 $obj->clean_in_place($data) => $cleaned
#
#Clean $data. Modify data in-place.
#
#=head2 $obj->clone_and_clean($data) => $cleaned
#
#Clean $data. Clone $data first.
#
#=head1 FAQ
#
#=head2 Why am I getting 'Modification of a read-only value attempted at lib/Data/Clean.pm line xxx'?
#
#[2013-10-15 ] This is also from Data::Clone::clone() when it encounters
#JSON::{PP,XS}::Boolean objects. You can use clean_in_place() instead of
#clone_and_clean(), or clone your data using other cloner like L<Sereal>.
#
#=head1 ENVIRONMENT
#
#LOG_CLEANSER_CODE
#
#=head1 HOMEPAGE
#
#Please visit the project's homepage at L<https://metacpan.org/release/Data-Clean-ForJSON>.
#
#=head1 SOURCE
#
#Source repository is at L<https://github.com/perlancar/perl-Data-Clean-ForJSON>.
#
#=head1 BUGS
#
#Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Clean-ForJSON>
#
#When submitting a bug or request, please include a test-file or a
#patch to an existing test-file that illustrates the bug or desired
#feature.
#
#=head1 AUTHOR
#
script/_ppgrep view on Meta::CPAN
# Rate Data::Dump Data::Dumper Data::Dmp
# Data::Dump 30417+-55/s -- -66.2% -74.0%
# Data::Dumper 89888+-79/s 195.52+-0.6% -- -23.1%
# Data::Dmp 116890+-160/s 284.29+-0.87% 30.04+-0.21% --
#
# [1..100]:
# Rate Data::Dump Data::Dmp Data::Dumper
# Data::Dump 3712.3+-7.9/s -- -73.9% -74.9%
# Data::Dmp 14211.3+-4.9/s 282.82+-0.82% -- -3.8%
# Data::Dumper 14771+-28/s 297.9+-1.1% 3.94+-0.2% --
#
# Some mixed structure:
# Rate Data::Dump Data::Dmp Data::Dumper
# Data::Dump 8764+-16/s -- -67.6% -80.1%
# Data::Dmp 27016+-36/s 208.28+-0.7% -- -38.6%
# Data::Dumper 43995+-13/s 402.02+-0.95% 62.85+-0.22% --
#
#=head1 FUNCTIONS
#
#=head2 dd($data, ...) => $data ...
#
#Exported by default. Like C<Data::Dump>'s C<dd> (a.k.a. C<dump>), print one or
#more data to STDOUT. Unlike C<Data::Dump>'s C<dd>, it I<always> prints and
#return I<the original data> (like L<XXX>), making it convenient to insert into
#expressions. This also removes ambiguity and saves one C<wantarray()> call.
#
#=head2 dmp($data, ...) => $str
#
#Exported by default. Return dump result as string. Unlike C<Data::Dump>'s C<dd>
#(a.k.a. C<dump>), it I<never> prints and only return the data.
#
#=head1 FAQ
#
#=head2 When to use Data::Dmp? How does it compare to other dumper modules?
#
#Data::Dmp might be suitable for you if you want a relatively fast pure-Perl data
#structure dumper to eval-able Perl code. It produces compact, single-line Perl
#code but offers little/no formatting options. Data::Dmp and Data::Dump module
#family usually produce Perl code that is "more eval-able", e.g. it can recreate
#circular structure.
#
#L<Data::Dump> produces visually nicer output (some alignment, use of range
#operator to shorten lists, use of base64 for binary data, etc) but no built-in
#option to produce compact/single-line output. It's more suitable for debugging.
#It's also relatively slow. I usually use its variant, L<Data::Dump::Color>, for
#console debugging.
#
#L<Data::Dumper> is a core module, offers a lot of formatting options (like
#disabling hash key sorting, setting verboseness/indent level, and so on) but you
#usually have to configure it quite a bit before it does exactly like you want
#(that's why there are modules on CPAN that are just wrapping Data::Dumper with
#some configuration, like L<Data::Dumper::Concise> et al). It does not support
#dumping Perl code that can recreate circular structures.
#
#Of course, dumping to eval-able Perl code is slow (not to mention the cost of
#re-loading the code back to in-memory data, via eval-ing) compared to dumping to
#JSON, YAML, Sereal, or other format. So you need to decide first whether this is
#the appropriate route you want to take. (But note that there is also
#L<Data::Dumper::Limited> and L<Data::Undump> which uses a format similar to
#Data::Dumper but lets you load the serialized data without eval-ing them, thus
#achieving the speed comparable to JSON::XS).
#
#=head2 Is the output guaranteed to be single line dump?
#
#No. Some things can still produce multiline dump, e.g. newline in regular
#expression.
#
#=head1 HOMEPAGE
#
#Please visit the project's homepage at L<https://metacpan.org/release/Data-Dmp>.
#
#=head1 SOURCE
#
#Source repository is at L<https://github.com/perlancar/perl-Data-Dmp>.
#
#=head1 BUGS
#
#Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Dmp>
#
#When submitting a bug or request, please include a test-file or a
#patch to an existing test-file that illustrates the bug or desired
#feature.
#
#=head1 SEE ALSO
#
#L<Data::Dump> and other variations/derivate works in Data::Dump::*.
#
#L<Data::Dumper> and its variants.
#
#L<Data::Printer>.
#
#L<YAML>, L<JSON>, L<Storable>, L<Sereal>, and other serialization formats.
#
#=head1 AUTHOR
#
#perlancar <perlancar@cpan.org>
#
#=head1 COPYRIGHT AND LICENSE
#
#This software is copyright (c) 2017 by perlancar@cpan.org.
#
#This is free software; you can redistribute it and/or modify it under
#the same terms as the Perl 5 programming language system itself.
#
#=cut
### Data/ModeMerge.pm ###
#package Data::ModeMerge;
#
#our $DATE = '2016-07-22'; # DATE
#our $VERSION = '0.35'; # VERSION
#
#use 5.010001;
#use strict;
#use warnings;
#
#use Mo qw(build default);
#
#require Exporter;
#our @ISA = qw(Exporter);
#our @EXPORT = qw(mode_merge);
#
( run in 1.681 second using v1.01-cache-2.11-cpan-39bf76dae61 )