Group
Extension

Matches 13

Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Serializer/JSON.pm ( view source; MetaCPAN )
package Dancer::Serializer::JSON;
our $AUTHORITY = 'cpan:SUKRIA';
#ABSTRACT: serializer for handling JSON data
$Dancer::Serializer::JSON::VERSION = '1.3521';
use strict;
use warnings;
use Carp;
use Da
r::Abstract';


# helpers

sub from_json {
    my $s = Dancer::Serializer::JSON->new;
    $s->deserialize(@_);
}

sub to_json {
    my $s = Dancer::Serializer::JSON->new;
    $s->serialize(@_);
}

# c
sub loaded { Dancer::ModuleLoader->load_with_params('JSON', '-support_by_pp') }

sub init {
    my ($self) = @_;
    raise core_serializer => 'JSON is needed and is not installed'
      unless $self->
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Serializer/Mutable.pm ( view source; MetaCPAN )
text/html'        => 'YAML',
    'text/xml'         => 'XML',
    'text/x-json'      => 'JSON',
    'application/json' => 'JSON',
};

my $loaded_serializer = {};
my $_content_type;

sub template_or_se
} 
            if $params && $params->{content_type};
    }
    push @content_types, 'application/json';

    # remove duplicates
    my %seen;
    return [ grep { not $seen{$_}++ } @content_types ];
 from the URL

=item

the B<accept> from the request headers

=item

The default is B<application/json>

=back

The content-type/serializer mapping that C<Dancer::Serializer::Mutable>
uses is

    ser
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Engine.pm ( view source; MetaCPAN )
 VERSION

version 1.3521

=head1 SYNOPSIS

    my $engine = Dancer::Engine->build( Serializer => 'JSON', $configuration );

=head1 DESCRIPTION

Dancer has various engines such Serializer engines, Temp
t it inherits from this
class.

=head1 ATTRIBUTES

=head2 name

The name of the engine, such as I<JSON>, or I<Simple>.

=head2 type

The type of the engine, such as I<Serializer>, or I<Session>.

=hea
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Introduction.pod ( view source; MetaCPAN )
 an example of a route handler that will return a HashRef

    use Dancer;
    set serializer => 'JSON';

    get '/user/:id/' => sub {
        { foo => 42,
          number => 100234,
          list 
ot
the case by default - Dancer renders the response via the current
serializer.

Hence, with the JSON serializer set, the route handler above would result in a
content like the following:

    {"numb
ey dynamically depend on
Perl modules you may not have on your system.

=over 4

=item B<JSON>

requires L<JSON>

=item B<YAML>

requires L<YAML>

=item B<XML>

requires L<XML::Simple>

=item B<Mutabl
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Cookbook.pod ( view source; MetaCPAN )
cer provides helpers to
serialize and deserialize for the following data formats:

=over 4

=item JSON

=item YAML

=item XML

=item Data::Dumper

=back

To activate this feature, you only have to set
he
format you require, for instance in your config.yml:

   serializer: JSON

Or right in your code:

   set serializer => 'JSON';

From now, all HashRefs or ArrayRefs returned by a route will be seri
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Serializer.pm ( view source; MetaCPAN )
 # don't create a new serializer unless it's defined in the config
    # (else it's created using json, and that's *not* what we want)
    my $serializer_name = Dancer::App->current->setting('serializ
$serializer_name);
    return;
}

sub init {
    my ($class, $name, $config) = @_;
    $name ||= 'JSON';
    $_engine = Dancer::Engine->build('serializer' => $name, $config);
    return $_engine;
}

#
e:

    serializer: "YAML"

Or in the application code:

    # setting JSON as the default serializer
    set serializer => 'JSON';

In your routes you can access parameters just like any route.

When
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Handler.pm ( view source; MetaCPAN )

}

sub _is_text {
    my ($content_type) = @_;
    return $content_type =~ /(\bx(?:ht)?ml\b|text|json|javascript)/;
}

# Fancy banner to print on startup
sub print_banner {
    if (setting('startup_i
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Development.pod ( view source; MetaCPAN )
n the author tests (in F</xt>) against the built code.

=item $ dzil listdeps --json

List all the dependencies, in JSON.

=item $ dzil build --notgz

Build the code, but don't generate the tarball.

Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Serializer/JSONP.pm ( view source; MetaCPAN )
package Dancer::Serializer::JSONP;
our $AUTHORITY = 'cpan:SUKRIA';
$Dancer::Serializer::JSONP::VERSION = '1.3521';
# ABSTRACT: serializer for handling JSONP data

use strict;
use warnings;
use Dancer:
:JSON';

sub serialize {
    my $self = shift;
	
	my $callback = Dancer::SharedData->request->params('query')->{callback};
	
	my $json = $self->SUPER::serialize(@_);
	
	return $callback . '(' . $json 
zer::JSONP - serializer for handling JSONP data

=head1 VERSION

version 1.3521

=head1 SYNOPSIS

=head1 DESCRIPTION

This class is a subclass of L<Dancer::Serializer::JSON> with support for JSONP.

I
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Plugin/Ajax.pm ( view source; MetaCPAN )
ritten
with plugin setting 'content_type'.

Here is example to use JSON:

  plugins:
    'Ajax':
      content_type: 'application/json'

=head1 AUTHOR

This module has been written by Alexis Sukrieh <
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Response.pm ( view source; MetaCPAN )


    # set the status
    $response->content_type('application/json');
    Dancer::SharedData->response->content_type('application/json');

Set or get the status of the current response object.

=hea
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer/Config.pm ( view source; MetaCPAN )
g it into some 8bit
charset, for example).

Also, since automatically serialized JSON responses have
C<application/json> Content-Type, you should always encode them by
hand.

Can also be set with envi
Dancer ( Y/YA/YANICK/Dancer-1.3521.tar.gz, YANICK, 2023; MetaCPAN )
Dancer/lib/Dancer.pm ( view source; MetaCPAN )
ancer::Hook;
use Dancer::Logger;
use Dancer::Renderer;
use Dancer::Route;
use Dancer::Serializer::JSON;
use Dancer::Serializer::YAML;
use Dancer::Serializer::XML;
use Dancer::Serializer::Dumper;
use D
er_version
  debug
  del
  dirname
  info
  error
  engine
  false
  forward
  from_dumper
  from_json
  from_yaml
  from_xml
  get
  halt
  header
  headers
  hook
  layout
  load
  load_app
  logger
error
  set
  setting
  set_cookie
  session
  splat
  status
  start
  template
  to_dumper
  to_json
  to_yaml
  to_xml
  true
  upload
  captures
  uri_for
  var
  vars
  warning
);

# Dancer's syn

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.