Subject: | Documentation - get rid of indirect object syntax |
There are several places that suggest the usage of:
my $json = new JSON::XS;
as opposed to:
my $json = JSON::XS->new;
Here's a patch to update those.
Subject: | xs.patch |
diff --git a/XS.pm b/XS.pm
index d09d9e3..328a315 100644
--- a/XS.pm
+++ b/XS.pm
-=item $json = new JSON::XS
+=item $json = JSON::XS->new
Creates a new JSON::XS object that can be used to de/encode JSON
strings. All boolean flags described below are by default I<disabled>.
@@ -808,7 +808,7 @@ the start of a string and identify the portion after the JSON object:
my $text = "[1,2,3] hello";
- my $json = new JSON::XS;
+ my $json = JSON::XS->new;
my $obj = $json->incr_parse ($text)
or die "expected JSON object or array at beginning of string";
@@ -828,7 +828,7 @@ with C<telnet>...).
Here is how you'd do it (it is trivial to write this in an event-based
manner):
- my $json = new JSON::XS;
+ my $json = JSON::XS->new;
# read some data from the socket
while (sysread $socket, my $buf, 4096) {
@@ -845,7 +845,7 @@ or arrays, all separated by (optional) comma characters (e.g. C<[1],[2],
and here is where the lvalue-ness of C<incr_text> comes in useful:
my $text = "[1],[2], [3]";
- my $json = new JSON::XS;
+ my $json = JSON::XS->new;
# void context, so no parsing done
$json->incr_parse ($text);
@@ -870,7 +870,7 @@ JSON decode the array elements, which are all full JSON objects on their
own (this wouldn't work if the array elements could be JSON numbers, for
example):
- my $json = new JSON::XS;
+ my $json = JSON::XS->new;
# open the monster
open my $fh, "<bigfile.json"
@@ -1626,4 +1626,3 @@ The F<json_xs> command line utility for quick experiments.
=cut
1
-