/[webpac2]/trunk/lib/WebPAC/Output/JSON.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Output/JSON.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1344 by dpavlin, Wed Oct 31 00:38:38 2007 UTC revision 1345 by dpavlin, Sat Oct 16 17:44:57 2010 UTC
# Line 9  __PACKAGE__->mk_accessors(qw(path)); Line 9  __PACKAGE__->mk_accessors(qw(path));
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10  use JSON;  use JSON;
11  use File::Slurp;  use File::Slurp;
12    use autodie;
13    
14  =head1 NAME  =head1 NAME
15    
# Line 97  sub finish { Line 98  sub finish {
98    
99          my $log = $self->_get_logger();          my $log = $self->_get_logger();
100    
101          $log->info("writing JSON output to ", $self->path);          if ( @{ $self->{_data} } ) {
102          write_file( $self->path, objToJson( { items => $self->{_data} } ) );  
103                    use bytes;
104    
105                    open(my $fh, '>', $self->path);
106                    print $fh to_json( { items => $self->{_data} } );
107                    close $fh;
108    
109                    $log->info("wrote JSON to ", $self->path, ' ', -s $self->path, ' bytes');
110    
111            } else {
112                    $log->error("no data for JSON generated - remove this output?");
113            }
114    
115  }  }
116    

Legend:
Removed from v.1344  
changed lines
  Added in v.1345

  ViewVC Help
Powered by ViewVC 1.1.26