1 package App
::Codeowners
::Formatter
::JSON
;
2 # ABSTRACT: Format codeowners output as JSON
6 This is a L<App::Codeowners::Formatter> that formats output using L<JSON::MaybeXS>.
13 our $VERSION = '9999.999'; # VERSION
15 use parent
'App::Codeowners::Formatter';
17 use App
::Codeowners
::Util
qw(zip);
21 If unset
(default), the output will be compact
. If
"pretty", the output will look nicer to humans
.
29 eval { require JSON
::MaybeXS
} or die "Missing dependency: JSON::MaybeXS\n";
32 $options{pretty
} = 1 if lc($self->format) eq 'pretty';
34 my $json = JSON
::MaybeXS-
>new(canonical
=> 1, utf8
=> 1, %options);
36 my $columns = $self->columns;
37 $results = [map { +{zip
@$columns, @$_} } @$results];
38 print { $self->handle } $json->encode($results);