ge Grimlock::Web::View::JSON;
{
$Grimlock::Web::View::JSON::VERSION = '0.11';
}
use strict;
use base 'Catalyst::View::JSON';
use JSON::XS ();
use Try::Tiny;
sub encode_json {
my($self, $c, $da
ta) = @_;
my $encoder = JSON::XS->new->ascii->allow_nonref->convert_blessed->allow_blessed;
$encoder->pretty if $c->debug;
my $d = $encoder->encode($data);
return $d;
}
sub process {
lf->encode_json($c, $data);
return $serialized;
}
=head1 NAME
Grimlock::Web::View::JSON - Catalyst JSON View
=head1 SYNOPSIS
See L<Grimlock::Web>
=head1 DESCRIPTION
Catalyst JSON View.
=h
'text/html' => [ 'View', 'HTML' ],
'application/json' => [ 'View', 'JSON' ],
'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Du
::Candy -components => [
qw(
InflateColumn::DateTime
TimeStamp
Helper::Row::ToJSON
EncodedColumn
)
];
use Data::Dumper;
use Text::Password::Pronounceable;
resultset_cl
}
);
}
sub TO_JSON {
my $self = shift;
return {
created_at => $self->created_at . "",
updated_at => $self->updated_at . "",
entries => $self->entries_TO_JSON,
%{ $self->next
::method },
};
}
sub entries_TO_JSON {
my $self = shift;
my $entry_rs = $self->entries;
my @entry_collection;
push @entry_collection, {
entryid => $_->entryid,
title => $_->title,
0.11';
}
use Grimlock::Schema::Candy -components => [
qw(
TimeStamp
Helper::Row::ToJSON
+DBICx::MaterializedPath
)
];
use HTML::Scrubber;
resultset_class 'Grimlock::Schema
ne->name;
return $date_time;
}
sub TO_JSON {
my $self = shift;
return {
reply_count => $self->reply_count,
children => $self->children_TO_JSON,
parent => $self->parent,
body
=> $self->body,
%{ $self->next::method },
}
}
sub children_TO_JSON {
my $self = shift;
my $children_rs = $self->children;
my @child_collection;
push @child_collection, {
entryid