- Timestamp:
- 06/05/15 19:32:33 (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bkmk
r88 r91 34 34 my $identifier = shift; 35 35 my $bookmark = find_bookmark($identifier); 36 print $bookmark ? Dump($bookmark-> TO_JSON) : "Not Found\n";36 print $bookmark ? Dump($bookmark->to_hashref) : "Not Found\n"; 37 37 }, 38 38 … … 41 41 my $title = defined $TITLE ? $TITLE : fetch_title($uri); 42 42 my $bookmark = $bookmarks->add({ uri => $uri, title => $title, tags => \@tags }); 43 print Dump($bookmark-> TO_JSON);43 print Dump($bookmark->to_hashref); 44 44 }, 45 45 … … 51 51 # TODO: list by tags, date, etc. 52 52 # TODO: coordinate this commandline script with the CGI app 53 print Dump([ map { $_-> TO_JSON} @{ $resources->results } ]);53 print Dump([ map { $_->to_hashref } @{ $resources->results } ]); 54 54 }, 55 55 … … 60 60 $bookmark->tags(\@tags); 61 61 $bookmarks->update($bookmark); 62 print Dump($bookmark-> TO_JSON);62 print Dump($bookmark->to_hashref); 63 63 } else { 64 64 die "Not found\n"; … … 77 77 dump => sub { 78 78 my ($dump_file) = @_; 79 my $dump = [ map { $_-> TO_JSON} @{ $bookmarks->search->results } ];79 my $dump = [ map { $_->to_hashref } @{ $bookmarks->search->results } ]; 80 80 $dump_file ? YAML::DumpFile($dump_file, $dump) : print Dump($dump); 81 81 }, -
trunk/lib/Bookmark.pm
r75 r91 32 32 } 33 33 34 sub TO_JSON{34 sub to_hashref { 35 35 my $self = shift; 36 36 return { -
trunk/lib/Bookmarks/Controller.pm
r88 r91 143 143 144 144 if ($format eq 'json') { 145 my $json = decode_utf8(JSON->new->utf8->convert_blessed->encode($bookmark ));145 my $json = decode_utf8(JSON->new->utf8->convert_blessed->encode($bookmark->to_hashref)); 146 146 return [200, ['Content-Type' => 'application/json; charset=UTF-8', 'Last-Modified' => $last_modified], [$json]]; 147 147 } else { -
trunk/lib/Bookmarks/List.pm
r88 r91 97 97 my $json = decode_utf8( 98 98 JSON->new->utf8->convert_blessed->encode({ 99 bookmarks => $self->results,99 bookmarks => [ map { $_->to_hashref } @{ $self->results } ], 100 100 }) 101 101 );
Note: See TracChangeset
for help on using the changeset viewer.