package Ambrosia::View::JSON;
use strict;
use warnings;
use Carp;
use JSON::XS ();
use Ambrosia::Meta;
class sealed
{
extends => [qw/Ambrosia::View/],
};
our $VERSION = 0.010;
sub process
{
return $self->as_json;
}
sub as_json
{
my $self = shift;
my $json = JSON::XS->new;
$json->utf8(0);
$json->latin1(1);
my $str = '';
eval
{
$json->convert_blessed
elf->data ? $json->encode($self->data) : '{}';
warn "$str\n";
};
if ( $@ )
{
carp "ERROR: $@";
}
return $str;
}
1;
__END__
=head1 NAME
Ambrosia::View::JSON - it is VIE
e);
}
1;
__END__
=head1 NAME
Ambrosia::View::JSON - it is VIEW in MVC.
=head1 VERSION
version 0.010
=head1 DESCRIPTION
C<Ambrosia::View::JSON> - it is VIEW in MVC.
Returns result in XML or HT
scriptName//;
my ($response_type, $resource_type, $resource_id) = ( $uri =~ m{/?(?:(html|xml|json|atom|rss)/)?([^?\\\/]*)(?:/([^?\\\/]+)?)?} );
$self->response_type = lc($response_type) || '
EntityCode($hDir{dirTemplates}, $tmplPath . '/Templates/Templates/' . $tpl_path . '/edit_json.xsl', '_edit_json' . $ex, 1, '@Type!="BIND" and @Type!="VIEW"');
copy($tmplPath . '/Templates/Template
y $style_doc = $self->parser->parse_file($tmplPath . '/Templates/Templates/' . $tpl_path . '/list_json.xsl');
($style_doc->getElementsByLocalName('output'))[0]->setAttribute( encoding => $enco
y $results = $stylesheet->transform($self->source);
my $fn = $hDir{dirTemplates} . '/list_json.xsl';
if ( -e $fn )
{
rename $fn, $fn . '.bak';
}
#if
[], ref $proto || $proto;
}
}
sub sub_nil
{
my $obj = shift;
sub { $obj };
}
sub TO_JSON
{
return {};
}
sub AUTOLOAD
{
unless ( defined wantarray ) # don't bother doing more
View>
The base class, which creates a view of the application.
The result can be represented in JSON, XML and HTML.
L<XML::LibXSLT> is used to generate HTML.
=item L<Ambrosia::Validator>
The class