package HTTP::Entity::Parser::JSON;
use strict;
use warnings;
use JSON::MaybeXS qw/decode_json/;
use Encode qw/encode_utf8/;
sub new {
bless [''], $_[0];
}
sub add {
my $self = shift;
i
{
$self->[0] .= $_[0];
}
}
sub finalize {
my $self = shift;
my $p = decode_json($self->[0]);
my @params;
if (ref $p eq 'HASH') {
while (my ($k, $v) = each %$p) {
::JSON - parser for application/json
=head1 SYNOPSIS
use HTTP::Entity::Parser;
my $parser = HTTP::Entity::Parser->new;
$parser->register('application/json','HTTP::Entity::Parser::JSON')
= 65536;
our %LOADED;
our @DEFAULT_PARSER = qw/
OctetStream
UrlEncoded
MultiPart
JSON
/;
for my $parser ( @DEFAULT_PARSER ) {
load "HTTP::Entity::Parser::".$parser;
$LOADED{"H
t/form-data','HTTP::Entity::Parser::MultiPart');
$parser->register('application/json','HTTP::Entity::Parser::JSON');
sub app {
my $env = shift;
my ( $params, $uploads) = $pars
s it.
This module supports application/x-www-form-urlencoded, multipart/form-data and application/json.
=head1 METHODS
=over 4
=item new( buffer_length => $length:Intger)
Create the instance.
=ov