Group
Extension

Matches 35

Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/JSON/Pointer.pm ( view source; MetaCPAN )
package Mojo::JSON::Pointer;
use Mojo::Base -base;

has 'data';

sub contains { shift->_pointer(0, @_) }
sub get      { shift->_pointer(1, @_) }

sub new { @_ > 1 ? shift->SUPER::new(data => shift) : 
a : 1;
}

1;

=encoding utf8

=head1 NAME

Mojo::JSON::Pointer - JSON Pointers

=head1 SYNOPSIS

  use Mojo::JSON::Pointer;

  my $pointer = Mojo::JSON::Pointer->new({foo => [23, 'bar']});
  say $poin
s('/foo');

=head1 DESCRIPTION

L<Mojo::JSON::Pointer> is an implementation of L<RFC 6901|https://tools.ietf.org/html/rfc6901>.

=head1 ATTRIBUTES

L<Mojo::JSON::Pointer> implements the following attr
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Guides/Testing.pod ( view source; MetaCPAN )
 = Test::Mojo->new('Celestial');

  # Post a JSON document
  $t->post_ok('/notifications' => json => {event => 'full moon'})
    ->status_is(201)
    ->json_is('/message' => 'notification created');

t->put_ok('/bees' => json => {type => 'worker', name => 'Karl'})
    ->status_is(202)
    ->json_has('/id');

  # Pull out the id from the response
  my $newbee = $t->tx->res->json('/id');

  # Make a
est with data from the previous response
  $t->get_ok("/bees/$newbee")
    ->status_is(200)
    ->json_is('/name' => 'Karl');

The L<Test::Mojo> object is I<stateful>. As long as we haven't started a 
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Renderer.pm ( view source; MetaCPAN )
;
use Mojo::Cache;
use Mojo::DynamicMethods;
use Mojo::File   qw(curfile path);
use Mojo::JSON   qw(encode_json);
use Mojo::Loader qw(data_section);
use Mojo::Util   qw(decamelize deprecated encode gz
{text}), $options->{format} if defined $stash->{text};

  # JSON
  return encode_json(delete $stash->{json}), 'json' if exists $stash->{json};

  # Template or templateless handler
  $options->{templa
licious::Controller->new);
  my $best = $renderer->accepts(Mojolicious::Controller->new, 'html', 'json');

Select best possible representation for L<Mojolicious::Controller> object from C<format> C<GE
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Lite.pm ( view source; MetaCPAN )
qr/\w+/];
  my $route = under '/:foo' => (agent => qr/Firefox/);
  my $route = under [format => ['json', 'yaml']];

Generate nested route with L<Mojolicious::Routes::Route/"under">, to which all follo
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Types.pm ( view source; MetaCPAN )
g'],
    jpg      => ['image/jpeg'],
    js       => ['application/javascript'],
    json     => ['application/json;charset=UTF-8'],
    mp3      => ['audio/mpeg'],
    mp4      => ['video/mp4'],
    
peg     -> image/jpeg
  jpg      -> image/jpeg
  js       -> application/javascript
  json     -> application/json;charset=UTF-8
  mp3      -> audio/mpeg
  mp4      -> video/mp4
  ogg      -> audio/og
ing new ones.

=head2 content_type

  $types->content_type(Mojolicious::Controller->new, {ext => 'json'});

Detect MIME type for L<Mojolicious::Controller> object unless a C<Content-Type> response hea
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Controller.pm ( view source; MetaCPAN )
->param('name');
    $self->res->headers->cache_control('max-age=1, no-cache');
    $self->render(json => {hello => $name});
  }

=head1 DESCRIPTION

L<Mojolicious::Controller> is the base class for y
ub ($c, $msg) {
    $c->app->log->debug("Message: $msg");
  });

  # Receive JSON object via WebSocket message
  $c->on(json => sub ($c, $hash) {
    $c->app->log->debug("Test: $hash->{test}");
  });
 = $c->render(data => $bytes);
  my $bool = $c->render(text => 'Hello!');
  my $bool = $c->render(json => {foo => 'bar'});
  my $bool = $c->render(handler => 'something');
  my $bool = $c->render('foo
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/Collection.pm ( view source; MetaCPAN )
 List::Util;
use Mojo::ByteStream;
use Scalar::Util qw(blessed);

our @EXPORT_OK = ('c');

sub TO_JSON { [@{shift()}] }

sub c { __PACKAGE__->new(@_) }

sub compact {
  my $self = shift;
  return $sel
head1 METHODS

L<Mojo::Collection> implements the following methods.

=head2 TO_JSON

  my $array = $collection->TO_JSON;

Alias for L</"to_array">.

=head2 compact

  my $new = $collection->compact;
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Sessions.pm ( view source; MetaCPAN )
package Mojolicious::Sessions;
use Mojo::Base -base;

use Mojo::JSON;
use Mojo::Util qw(b64_decode b64_encode);

has [qw(cookie_domain encrypted secure)];
has cookie_name        => 'mojolicious';
has 
padding are no longer a concern)
sub _deserialize { Mojo::JSON::decode_json($_[0] =~ s/\}\KZ*$//r) }

sub _serialize { Mojo::JSON::encode_json($_[0]) }

1;

=encoding utf8

=head1 NAME

Mojolicious::S
anages sessions based on signed cookies for L<Mojolicious>. All data gets serialized with
L<Mojo::JSON> and stored Base64 encoded on the client-side, but is protected from unwanted changes with a HMAC
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Test/Mojo.pm ( view source; MetaCPAN )
lling you, dude.
#  Fry: Santa Claus is gunning you down!"
use Mojo::IOLoop;
use Mojo::JSON qw(j);
use Mojo::JSON::Pointer;
use Mojo::Server;
use Mojo::UserAgent;
use Mojo::Util qw(decode encode);
use
"));
}

sub json_has {
  my ($self, $p, $desc) = @_;
  $desc = _desc($desc, qq{has value for JSON Pointer "$p"});
  return $self->test('ok', !!Mojo::JSON::Pointer->new($self->tx->res->json)->contains(
);
}

sub json_hasnt {
  my ($self, $p, $desc) = @_;
  $desc = _desc($desc, qq{has no value for JSON Pointer "$p"});
  return $self->test('ok', !Mojo::JSON::Pointer->new($self->tx->res->json)->contain
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/JSON.pm ( view source; MetaCPAN )
package Mojo::JSON;
use Mojo::Base -strict;

use Carp         qw(croak);
use Exporter     qw(import);
use JSON::PP     ();
use Mojo::Util   qw(decode encode monkey_patch);
use Scalar::Util qw(blessed)
;

# For better performance Cpanel::JSON::XS is required
use constant JSON_XS => $ENV{MOJO_NO_JSON_XS}
  ? 0
  : !!eval { require Cpanel::JSON::XS; Cpanel::JSON::XS->VERSION('4.09'); 1 };

use constan
unimport('experimental::builtin') if CORE_BOOLS;
}

our @EXPORT_OK = qw(decode_json encode_json false from_json j to_json true);

# Escaped special character map
my %ESCAPE
  = ('"' => '"', '\\' => '\
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Plugins.pm ( view source; MetaCPAN )
ute condition for all kinds of headers, loaded automatically.

=item L<Mojolicious::Plugin::JSONConfig>

JSON configuration files.

=item L<Mojolicious::Plugin::Mount>

Mount whole L<Mojolicious> appl
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo.pm ( view source; MetaCPAN )
<Mojolicious>. Some of the most commonly used tools are L<Mojo::UserAgent>,
L<Mojo::DOM>, L<Mojo::JSON>, L<Mojo::Server::Daemon>, L<Mojo::Server::Prefork>, L<Mojo::IOLoop> and L<Mojo::Template>.

See 
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/UserAgent.pm ( view source; MetaCPAN )

  # Quick JSON API request with Basic authentication
  my $url = Mojo::URL->new('https://example.com/test.json')->userinfo('sri:☃');
  my $value = $ua->get($url)->result->json;

  # JSON POST (appl
ate authentication
  my $tx = $ua->cert('tls.crt')->key('tls.key')->post('https://example.com' => json => {top => 'secret'});

  # Form POST (application/x-www-form-urlencoded)
  my $tx = $ua->post('h
ocks://127.0.0.1:9050');
  say $ua->get('api.3g2upl4pq6kufc4m.onion/?q=mojolicious&format=json')->result->json('/Abstract');

  # GET request via UNIX domain socket "/tmp/myapp.sock" (percent encoded 
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious.pm ( view source; MetaCPAN )
ion_format;
  $app       = $app->exception_format('txt');

Format for HTTP exceptions (C<html>, C<json>, or C<txt>), defaults to C<html>.

=head2 home

  my $home = $app->home;
  $app     = $app->home
rse an excessively large request body with the methods L<Mojo::Message/"dom"> or
L<Mojo::Message/"json">.

=head2 mode

  my $mode = $app->mode;
  $app     = $app->mode('production');

The operating m
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/Message.pm ( view source; MetaCPAN )
w(croak);
use Mojo::Asset::Memory;
use Mojo::Content::Single;
use Mojo::DOM;
use Mojo::JSON qw(j);
use Mojo::JSON::Pointer;
use Mojo::Parameters;
use Mojo::Upload;
use Mojo::Util qw(decode);

has cont
ift->{limit} }

sub json {
  my ($self, $pointer) = @_;
  return undef if $self->content->is_multipart;
  my $data = $self->{json} //= j($self->body);
  return $pointer ? Mojo::JSON::Pointer->new($dat
ojo::Headers/"max_line_size">.

=head2 json

  my $value = $msg->json;
  my $value = $msg->json('/foo/bar');

Decode JSON message body directly using L<Mojo::JSON> if possible, an C<undef> return valu
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/Headers.pm ( view source; MetaCPAN )
rs:

=head2 accept

  my $accept = $headers->accept;
  $headers   = $headers->accept('application/json');

Get or replace current header value, shortcut for the C<Accept> header.

=head2 accept_charse
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/Transaction.pm ( view source; MetaCPAN )
->req->params->to_hash;
  my $all    = $tx->req->uploads;
  my $value  = $tx->req->json;
  my $foo    = $tx->req->json('/23/foo');
  my $dom    = $tx->req->dom;
  my $bar    = $tx->req->dom('div.bar')
tes   = $tx->res->body;
  my $str     = $tx->res->text;
  my $value   = $tx->res->json;
  my $foo     = $tx->res->json('/23/foo');
  my $dom     = $tx->res->dom;
  my $bar     = $tx->res->dom('div.bar
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Guides.pod ( view source; MetaCPAN )
Very fun and minimalistic HTML/XML DOM parser with CSS selector support.

=item L<Mojo::JSON>

Minimalistic JSON implementation that just works.

=item L<Mojo::Server::Daemon>

Full featured, highly p
jolicious::Plugins>

=back

=item * L<Mojo::Exception>

=item * L<Mojo::Headers>

=item * L<Mojo::JSON::Pointer>

=item * L<Mojo::Parameters>

=item * L<Mojo::Path>

=item * L<Mojo::Promise>

=item * 
Plugin>

=over 2

=item * L<Mojolicious::Plugin::Config>

=over 2

=item * L<Mojolicious::Plugin::JSONConfig>

=over 2

=item * L<Mojolicious::Plugin::NotYAMLConfig>

=back

=back

=item * L<Mojolicio
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojo/Transaction/HTTP.pm ( view source; MetaCPAN )
od('GET');
  $tx->req->url->parse('http://example.com');
  $tx->req->headers->accept('application/json');
  say $tx->res->code;
  say $tx->res->headers->content_type;
  say $tx->res->body;
  say $tx->
Mojolicious ( S/SR/SRI/Mojolicious-9.41.tar.gz, SRI, 2025; MetaCPAN )
Mojolicious/lib/Mojolicious/Guides/Tutorial.pod ( view source; MetaCPAN )
ho

=head2 JSON

JSON is the most commonly used data-interchange format for web services. L<Mojolicious> loves JSON and comes with the
possibly fastest pure-Perl implementation L<Mojo::JSON> built rig
h is accessible through
L<Mojo::Message/"json"> as well as the reserved stash value C<json>.

  use Mojolicious::Lite -signatures;

  # Modify the received JSON document and return it
  put '/reverse'
q->json;
    $hash->{message} = reverse $hash->{message};
    $c->render(json => $hash);
  };

  app->start;

You can send JSON documents from the command line with L<Mojolicious::Command::get>.

  $ 

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