use Data::Dump qw/dump/;
use JSON;
use File::Slurp;
+use autodie;
=head1 NAME
my $log = $self->_get_logger();
- $log->info("writing JSON output to ", $self->path);
- write_file( $self->path, objToJson( { items => $self->{_data} } ) );
+ if ( @{ $self->{_data} } ) {
+
+ use bytes;
+
+ open(my $fh, '>', $self->path);
+ print $fh to_json( { items => $self->{_data} } );
+ close $fh;
+
+ $log->info("wrote JSON to ", $self->path, ' ', -s $self->path, ' bytes');
+
+ } else {
+ $log->error("no data for JSON generated - remove this output?");
+ }
}