- Improve data_root & item_root documentation
- Fix grouped_by request argument documentation
- Don't overwrite already set response data when return_object is enabled
+ - Use JSON::MaybeXS for improved performance
2.006002 2014-08-26 12:31:27+02:00 Europe/Vienna
- Fix missing Data::Printer test requirement
Catalyst::Runtime = 5.90020
Catalyst::Action::Serialize = 0.83
CGI::Expand = 2.02
-JSON = 2.50
+JSON::MaybeXS = 1.004000
Data::DPath::Validator = 0.093411
Catalyst::Model::DBIC::Schema = 0.20
MooseX::Types::Structured = 0.20
use CGI::Expand ();
use DBIx::Class::ResultClass::HashRefInflator;
-use JSON ();
+use JSON::MaybeXS ();
use Test::Deep::NoTest('eq_deeply');
use MooseX::Types::Moose(':all');
use Moose::Util;
has '_json' => (
is => 'ro',
- isa => 'JSON',
+ isa => JSON::MaybeXS::JSON(),
lazy_build => 1,
);
sub _build__json {
# no ->utf8 here because the request params get decoded by Catalyst
- return JSON->new;
+ return JSON::MaybeXS->new;
}
with 'Catalyst::Controller::DBIC::API::StoredResultSource',
}
# check for multiple values
- if ( ref($value) && !( reftype($value) eq reftype(JSON::true) ) )
+ if ( ref($value) && !( reftype($value) eq reftype(JSON::MaybeXS::true) ) )
{
require Data::Dumper;
die
foreach my $key ( keys %$params ) {
my $value = $params->{$key};
- if ( ref($value) && !( reftype($value) eq reftype(JSON::true) ) ) {
+ if ( ref($value) && !( reftype($value) eq reftype(JSON::MaybeXS::true) ) ) {
$self->update_object_relation( $c, $object,
delete $params->{$key}, $key );
}
if ($row) {
foreach my $key ( keys %$related_params ) {
my $value = $related_params->{$key};
- if ( ref($value) && !( reftype($value) eq reftype(JSON::true) ) )
+ if ( ref($value) && !( reftype($value) eq reftype(JSON::MaybeXS::true) ) )
{
$self->update_object_relation( $c, $row,
delete $related_params->{$key}, $key );
my %rels;
while ( my ( $key, $value ) = each %{$params} ) {
- if ( ref($value) && !( reftype($value) eq reftype(JSON::true) ) ) {
+ if ( ref($value) && !( reftype($value) eq reftype(JSON::MaybeXS::true) ) ) {
$rels{$key} = $value;
}
if ( $c->res->status == 200 ) {
$c->stash->{ $self->stash_key }->{success} =
- $self->use_json_boolean ? JSON::true : 'true';
+ $self->use_json_boolean ? JSON::MaybeXS::true : 'true';
if ( $self->return_object
&& $c->req->has_objects
&& ! exists $c->stash->{ $self->stash_key }->{ $self->data_root } ) {
}
else {
$c->stash->{ $self->stash_key }->{success} =
- $self->use_json_boolean ? JSON::false : 'false';
+ $self->use_json_boolean ? JSON::MaybeXS::false : 'false';
$c->stash->{ $self->stash_key }->{messages} = $self->get_errors($c)
if $self->has_errors($c);
=head3 use_json_boolean
By default, the response success status is set to a string value of "true" or
-"false". If this attribute is true, JSON's true() and false() will be used
-instead. Note, this does not effect other internal processing of boolean values.
+"false". If this attribute is true, JSON::MaybeXS's true() and false() will be
+used instead. Note, this does not effect other internal processing of boolean
+values.
=head3 count_arg, page_arg, select_arg, search_arg, grouped_by_arg, ordered_by_arg, prefetch_arg, as_arg, total_entries_arg
and its role system to refactor functionality out into self-contained roles.
To this end, internally, this module now understands JSON boolean values (as
-represented by the JSON module) and will Do The Right Thing in handling those
-values. This means you can have ColumnInflators installed that can covert
-between JSON booleans and whatever your database wants for boolean values.
+represented by the JSON::MaybeXS module) and will Do The Right Thing in
+handling those values. This means you can have ColumnInflators installed that
+can covert between JSON booleans and whatever your database wants for boolean
+values.
Validation for various *_allows or *_exposes is now accomplished via
Data::DPath::Validator with a lightly simplified, via a subclass of
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
is( $rs->count, 3, 'no records created' );
my $response = $json->decode( $mech->content );
- is( $response->{success}, JSON::false,
+ is( $response->{success}, JSON::MaybeXS::false,
'success property returns unquoted false' );
like(
$response->{messages}->[0],
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common qw/ DELETE /;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
$response,
# track does set use_json_boolean
- { data => \%expected_response, success => JSON::true },
+ { data => \%expected_response, success => JSON::MaybeXS::true },
'correct data returned for track with datetime'
);
}
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
use Data::Printer;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
$response,
# track does set use_json_boolean
- { list => \@expected_response, success => JSON::true, totalcount => 15 },
+ { list => \@expected_response, success => JSON::MaybeXS::true, totalcount => 15 },
'correct data returned for static configured paging'
);
}
is_deeply(
$response,
# track does set use_json_boolean
- { list => \@expected_response, success => JSON::true, totalcount => 2 },
+ { list => \@expected_response, success => JSON::MaybeXS::true, totalcount => 2 },
'correct data returned for -and|-or search param'
)
or diag p($case) . p($response);
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
$mech->request($req);
cmp_ok( $mech->status, '==', 400, 'Attempt to update three tracks fails' );
my $response = $json->decode( $mech->content );
- is( $response->{success}, JSON::false,
+ is( $response->{success}, JSON::MaybeXS::false,
'success property returns unquoted false' );
like(
$response->{messages}->[0],
cmp_ok( $mech->status, '==', 400,
'Attempt to update three nonexisting tracks fails' );
my $response = $json->decode( $mech->content );
- is( $response->{success}, JSON::false,
+ is( $response->{success}, JSON::MaybeXS::false,
'success property returns unquoted false' );
like(
$response->{messages}->[0],
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More tests => 17;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );
use Test::More;
use Test::WWW::Mechanize::Catalyst 'RestTest';
use HTTP::Request::Common;
-use JSON;
+use JSON::MaybeXS;
-my $json = JSON->new->utf8;
+my $json = JSON::MaybeXS->new(utf8 => 1);
my $mech = Test::WWW::Mechanize::Catalyst->new;
ok( my $schema = DBICTest->init_schema(), 'got schema' );