From: Karen Etheridge Date: Fri, 4 Aug 2017 20:12:15 +0000 (-0700) Subject: add parentheses so as to not imply we are using JSON.pm X-Git-Tag: v1.003010~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20f884e267e92537b6b5fca6a8ba5e24b7d6b378;p=p5sagit%2FJSON-MaybeXS.git add parentheses so as to not imply we are using JSON.pm --- diff --git a/lib/JSON/MaybeXS.pm b/lib/JSON/MaybeXS.pm index f71d0d5..64d13f2 100644 --- a/lib/JSON/MaybeXS.pm +++ b/lib/JSON/MaybeXS.pm @@ -111,7 +111,7 @@ JSON::MaybeXS - Use L with a fallback to L and Lnew; + my $json = JSON()->new; my $json_with_args = JSON::MaybeXS->new(utf8 => 1); # or { utf8 => 1 } @@ -181,12 +181,15 @@ B. The C constant returns the selected implementation module's name for use as a class name - so: - my $json_obj = JSON->new; # returns a Cpanel::JSON::XS or JSON::PP object + my $json_obj = JSON()->new; # returns a Cpanel::JSON::XS or JSON::PP object and that object can then be used normally: my $data_structure = $json_obj->decode($json_text); # etc. +The use of parentheses here is optional, and only used as a hint to the reader +that this use of C is a I call, I a class name. + =head2 is_bool $is_boolean = is_bool($scalar) @@ -223,8 +226,8 @@ least) the methods C and C. To include JSON-aware booleans (C, C) in your data, just do: use JSON::MaybeXS; - my $true = JSON->true; - my $false = JSON->false; + my $true = JSON()->true; + my $false = JSON()->false; =head1 CONVERTING FROM JSON::Any diff --git a/t/legacy.t b/t/legacy.t index fb5cc19..1df4790 100644 --- a/t/legacy.t +++ b/t/legacy.t @@ -42,7 +42,7 @@ __END__ This function call is functionally identical to: - $json_text = JSON->new->encode($perl_scalar) + $json_text = JSON()->new->encode($perl_scalar) from_json $perl_scalar = from_json($json_text) @@ -52,4 +52,4 @@ __END__ This function call is functionally identical to: - $perl_scalar = JSON->decode($json_text) + $perl_scalar = JSON()->decode($json_text) diff --git a/xt/json_pm.t b/xt/json_pm.t index 56beae9..f2d6a59 100644 --- a/xt/json_pm.t +++ b/xt/json_pm.t @@ -6,7 +6,7 @@ unless ( eval { require JSON; 1 } ) { plan skip_all => 'No JSON'; } -my $data = JSON->new->decode('{"foo": true, "bar": false, "baz": 1}'); +my $data = JSON()->new->decode('{"foo": true, "bar": false, "baz": 1}'); ok( JSON::is_bool($data->{foo}),