/[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 881 by dpavlin, Thu Aug 23 20:28:09 2007 UTC revision 913 by dpavlin, Tue Oct 30 20:11:02 2007 UTC
# Line 3  package WebPAC::Output::JSON; Line 3  package WebPAC::Output::JSON;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6  use base qw/WebPAC::Common Class::Accessor/;  use base qw/WebPAC::Common WebPAC::Output Class::Accessor/;
7  __PACKAGE__->mk_accessors(qw(path));  __PACKAGE__->mk_accessors(qw(path));
8    
9  use Encode qw/from_to/;  #use Encode qw/from_to/;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11    use JSON;
12    use File::Slurp;
13    
14  =head1 NAME  =head1 NAME
15    
# Line 55  sub init { Line 57  sub init {
57    
58          $log->debug('init');          $log->debug('init');
59    
60            $self->{_data} = [];
61    
62          return 1;          return 1;
63  }  }
64    
# Line 78  sub add { Line 82  sub add {
82    
83          $log->debug("id: $id ds = ",dump($ds));          $log->debug("id: $id ds = ",dump($ds));
84    
85            push @{ $self->{_data} }, $self->ds_to_hash( $ds, 'display' );
86    
87          return 1;          return 1;
88  }  }
89    
# Line 92  sub finish { Line 98  sub finish {
98    
99          my $log = $self->_get_logger();          my $log = $self->_get_logger();
100    
101          $log->info("finish");          $log->info("writing JSON output to ", $self->path);
102            write_file( $self->path, objToJson( { items => $self->{_data} } ) );
103    
104  }  }
105    

Legend:
Removed from v.881  
changed lines
  Added in v.913

  ViewVC Help
Powered by ViewVC 1.1.26