diff options
author | Dan Book <grinnz@grinnz.com> | 2020-02-24 11:31:58 -0500 |
---|---|---|
committer | Aran Clary Deltac <bluefeet@gmail.com> | 2023-06-07 13:15:52 -0700 |
commit | 5d50cbc54376e58304cee3a60a9bbb0bc8d1f382 (patch) | |
tree | 5b8ac67e55cc74f38d72bbbd50e9756cf012a445 | |
parent | dc1afe207ab3fc46ead31ca60003a326ec2f339a (diff) |
use JSON::MaybeXS constructor
-rw-r--r-- | lib/GitLab/API/v4/Config.pm | 4 | ||||
-rw-r--r-- | lib/GitLab/API/v4/RESTClient.pm | 2 | ||||
-rwxr-xr-x | script/gitlab-api-v4 | 2 | ||||
-rwxr-xr-x | t/gitlab-api-v4.t | 4 |
4 files changed, 5 insertions, 7 deletions
diff --git a/lib/GitLab/API/v4/Config.pm b/lib/GitLab/API/v4/Config.pm index 3acd7fd..86c9c2c 100644 --- a/lib/GitLab/API/v4/Config.pm +++ b/lib/GitLab/API/v4/Config.pm @@ -236,9 +236,7 @@ sub configure { '-stdio', '-verbatim', ); - my $json = JSON->new - ->pretty - ->canonical + my $json = JSON::MaybeXS->new(pretty => 1, canonical => 1) ->encode({ $url ? (url=>$url) : (), $private_token ? (private_token=>$private_token) : (), diff --git a/lib/GitLab/API/v4/RESTClient.pm b/lib/GitLab/API/v4/RESTClient.pm index 8f7fae2..cd0900a 100644 --- a/lib/GitLab/API/v4/RESTClient.pm +++ b/lib/GitLab/API/v4/RESTClient.pm @@ -110,7 +110,7 @@ has json => ( isa => HasMethods[ 'encode', 'decode' ], ); sub _build_json { - return JSON->new->utf8->allow_nonref(); + return JSON::MaybeXS->new(utf8 => 1, allow_nonref => 1); } has http_tiny_request => ( diff --git a/script/gitlab-api-v4 b/script/gitlab-api-v4 index 6ab4a22..6d80343 100755 --- a/script/gitlab-api-v4 +++ b/script/gitlab-api-v4 @@ -120,7 +120,7 @@ my $data = $api->$method( $data = $data->all() if $all; binmode STDOUT, ':utf8'; -my $json = JSON->new->allow_nonref(); +my $json = JSON::MaybeXS->new(allow_nonref => 1); $json->pretty() if $pretty; $json->canonical() if $canonical; print $json->encode( $data ); diff --git a/t/gitlab-api-v4.t b/t/gitlab-api-v4.t index c469b65..028e390 100755 --- a/t/gitlab-api-v4.t +++ b/t/gitlab-api-v4.t @@ -5,9 +5,9 @@ use Test2::Require::AuthorTesting; use Test2::V0; use IPC::Cmd qw(); -use JSON::MaybeXS qw(JSON); +use JSON::MaybeXS qw(); -my $json = JSON->new->allow_nonref(); +my $json = JSON::MaybeXS->new(allow_nonref => 1); my $project = run('create-project', 'name:test-gitlab-api-v4'); run('delete-project', $project->{id}); |