CatalystX::Usul::View::JSON - Render JSON response to an XMLHttpRequest


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

Index


Code Index:

Name

Top

CatalystX::Usul::View::JSON - Render JSON response to an XMLHttpRequest

Version

Top

0.3.$Revision: 576 $

Synopsis

Top

   MyApp->config( "View::JSON"   => {
                     base_class => qw(CatalystX::Usul::View::JSON) } );

Description

Top

The JSON view is used to generate JSON data blocks in response to Javascript XMLHttpRequests from a client that has selected this as the required content type

Subroutines/Methods

Top

deserialize

Decodes the supplied data. Calls decode_json to get the work done

serialize

Returns the supplied data encoded as JSON. Calls decode_json to get the work done

Diagnostics

Top

None

Configuration and Environment

Top

None

Dependencies

Top

Catalyst::View
JSON

Incompatibilities

Top

There are no known incompatibilities in this module

Bugs and Limitations

Top

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Top

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Top


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

# @(#)$Id: JSON.pm 576 2009-06-09 23:23:46Z pjf $

package CatalystX::Usul::View::JSON;

use strict;
use warnings;
use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 576 $ =~ /\d+/gmx );
use parent qw(CatalystX::Usul::View);

use Class::C3;
use JSON qw(decode_json encode_json);

sub deserialize {
   my ($self, @rest) = @_;

   my $process = sub { return decode_json( $_[1] ); };

   return $self->next::method( @rest, $process );
}

sub serialize {
   my ($self, $attrs, $data) = @_; return encode_json( $data );
}

1;

__END__

# Local Variables:
# mode: perl
# tab-width: 3
# End: