=encoding utf-8
=head1 NAME
MouseX::OO_Modulino - Turn your Mouse class into JSON-aware Object-Oriented Modulino.
=head1 SYNOPSIS
#!/usr/bin/env perl
package MyModule;
use MouseX::OO_M
d to the method.
Option format: C<--name> or C<--name=value> (no space between name and value).
JSON values in options and arguments are automatically decoded:
=for code sh
$ ./MyScript.pm --con
ar context (default is list context)
=item C<--output=FORMAT>
Output format: C<jsonl> (default), C<json>(alias of jsonl), C<dump>
=item C<--undef_as=STRING>
How to represent undef in TSV output (d
use JSON::MaybeXS ();
use constant USING_CPANEL_JSON_XS => JSON::MaybeXS::JSON()->isa("Cpanel::JSON::XS");
#========================================
has output => (is => 'rw', default => 'jsonl');
es;
}
\@res;
}
sub cli_output {
my ($self, $item) = @_;
my $format = $self->output // "jsonl";
my $emitter = $self->can("cli_write_fh_as_$format")
or Carp::croak "No such output form
s_json = *cli_write_fh_as_jsonl; *cli_write_fh_as_json = *cli_write_fh_as_jsonl;
sub cli_write_fh_as_jsonl {
my ($self, $outFH, $item) = @_;
print $outFH (
ref $item ? $self->cli_encode_json($