NAME
Data::Clean::Base - Base class for Data::Clean::*
METHODS
new(%opts) => $obj
Create a new instance.
Options specify what to do with problematic data. Option keys are either reference types or class names, or -obj
(to refer to objects, a.k.a. blessed references), -circular
(to refer to circular references), -ref
(to refer to references, used to process references not handled by other options). Option values are arrayrefs, the first element of the array is command name, to specify what to do with the reference/class. The rest are command arguments. Available commands:
['stringify']
This will stringify a reference like
{}
to something likeHASH(0x135f998)
.['replace_with_ref']
This will replace a reference like
{}
withHASH
.['replace_with_str', STR]
This will replace a reference like
{}
with STR.['call_method']
This will call a method and use its return as the replacement. For example: DateTime->from_epoch(epoch=>1000) when processed with [call_method => 'epoch'] will become 1000.
['call_func', STR]
This will call a function named STR with value as argument and use its return as the replacement.
['one_or_zero', STR]
This will perform
$val ? 1:0
.['deref_scalar']
This will replace a scalar reference like \1 with 1.
['unbless']
This will perform unblessing using Acme::Damn. Should be done only for objects (
-obj
).['code', STR]
This will replace with STR treated as Perl code.
Example:
obj => ''
Special commands for -circular
:
['detect_circular']
Keep a count for each reference. When a circular reference is found, replace it with <"CIRCULAR">.
Default options:
-ref => 'stringify'
Note that arrayrefs and hashrefs are always walked into, so it's not trapped by -ref
.
$obj->clean_in_place($data) => $cleaned
Clean $data. Modify data in-place.
$obj->clone_and_clean($data) => $cleaned
Clean $data. Clone $data first.
ENVIRONMENT
LOG_CLEANSER_CODE => BOOL (default: 0)
Can be enabled if you want to see the generated cleanser code. It is logged at level
trace
.LINENUM => BOOL (default: 1)
When logging cleanser code, whether to give line numbers.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Data-Clean-JSON.
SOURCE
Source repository is at https://github.com/sharyanto/perl-Data-Clean-JSON.
BUGS
Please report any bugs or feature requests on the bugtracker website http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Clean-JSON
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.
AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.