Group
Extension

Matches 8

CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel/ContentBodyParser/JSON.pm ( view source; MetaCPAN )
tBodyParser::JSON;

use warnings;
use strict;
use CatalystX::RequestModel::Utils::InvalidJSON;

use base 'CatalystX::RequestModel::ContentBodyParser';

sub content_type { 'application/json' }

sub def
>_parse_json_body;
  return $self;
}

sub _parse_json_body {
  my ($self) = @_;
  my $json = eval {
    $self->{ctx}->req->body_data;
  } || do {
    CatalystX::RequestModel::Utils::InvalidJSON->throw
g_error=>$@);
  };

  return $json;
}

1;

=head1 NAME

CatalystX::RequestModel::ContentBodyParser::JSON

=head1 SYNOPSIS

    TBD

=head1 DESCRIPTION

Given a valid JSON request body, parse it and in
CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel/Utils/InvalidRequestNamespace.pm ( view source; MetaCPAN )
X::Utils::DoesHttpException';
 
has 'ns' => (is=>'ro', required=>1);

sub status_code { 400 }
sub error { "JSON Request does not have namespace: @{[ $_[0]->ns]}" }

__PACKAGE__->meta->make_immutable;
CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel/DoesRequestModel.pm ( view source; MetaCPAN )
;
    has last_name => (is=>'ro', property=>1);
    has notes => (is=>'ro', property=>+{ expand=>'JSON' });

See L<CatalystX::RequestModel> for a more general overview.

=head1 DESCRIPTION

A role tha
CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel.pm ( view source; MetaCPAN )
 you can read about below.

See L<CatalystX::RequestModel::ContentBodyParser::JSON> for an example of using this with JSON
request content.

=head1 DESCRIPTION

Dealing with incoming POSTed (or PUTed/
 for handling common incoming
content types such as form URL encoded (common with HTML forms) and JSON as well as the ability to
add in parsing for other types of contents (see L<Catalyst#DATA-HANDLER
 should be able to build upon the meta data
it exposed to do things like auto generate Open API / JSON Schema definition files (TBD but possible).

Basically you convert an unknown hash of values into
CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel/ContentBodyParser.pm ( view source; MetaCPAN )
er;

use warnings;
use strict;
use Module::Runtime ();
use CatalystX::RequestModel::Utils::InvalidJSONForValue;
use CatalystX::RequestModel::Utils::InvalidRequestNamespace;
use CatalystX::RequestModel
del}) {


        $context->{$data_name} = $self->normalize_json($context->{$data_name}, $data_name) if (($attr_rules->{expand}||'') eq 'JSON');
        $context->{$data_name} = $self->normalize_boole
$self, $param, $value, $key_rules) = @_;

  $value = $self->normalize_json($value, $param) if (($key_rules->{expand}||'') eq 'JSON');

  if($key_rules->{always_array}) {
    $value = $self->normalize_
CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel/Utils/InvalidJSON.pm ( view source; MetaCPAN )
stModel::Utils::InvalidJSON;
 
use Moose;
with 'CatalystX::Utils::DoesHttpException';
 
has 'parsing_error' => (is=>'ro', required=>1);

sub status_code { 400 }
sub error { "JSON decode error ': @{[ $
CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/RequestModel/Utils/InvalidJSONForValue.pm ( view source; MetaCPAN )
package CatalystX::RequestModel::Utils::InvalidJSONForValue;
 
use Moose;
with 'CatalystX::Utils::DoesHttpException';
 
has 'param' => (is=>'ro', required=>1);
has 'value' => (is=>'ro', required=>1);
has 'parsing_error' => (is=>'ro', required=>1);

sub status_code { 400 }
sub error { "JSON decode error for parameter '@{[ $_[0]->param]}', value '@{[ $_[0]->value ]}': @{[ $_[0]->parsing_error]}" }

CatalystX-RequestModel ( J/JJ/JJNAPIORK/CatalystX-RequestModel-0.020.tar.gz, JJNAPIORK, 2025; MetaCPAN )
CatalystX-RequestModel/lib/CatalystX/QueryModel.pm ( view source; MetaCPAN )
you have special handling needs.  For example:

    has notes => (is=>'ro', property=>+{ expand=>'JSON' });

Here's the current list of property settings and what they do.  You can also request the te
ay those formats work you can't be sure if a value is flat or an array. This isn't a problem with
JSON encoded request bodies.  You'll need to check the docs for the Content Body Parser you are using 
g it.   Right now there's only one value this will take,
which is C<JSON> and will then parse the value into a structure using a JSON parser.   Again this is mostly
useful for HTML form posting and co

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