summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgregor herrmann <gregoa@debian.org>2021-01-07 02:44:31 +0100
committergregor herrmann <gregoa@debian.org>2021-01-07 02:44:31 +0100
commitc94699d9cf62477f6ca6682ff1057e8fc9eb5c0d (patch)
treecd503e2e471e73abd11204ab1250eef4ef5574e5
parent582923da918ba394cda5698d8d7ae9af9ca979f2 (diff)
parent4441e009ac37b3d41dd39800a22e2af77598e434 (diff)
Update upstream source from tag 'upstream/0.59'
Update to upstream version '0.59' with Debian dir 79b3c24eb3822d0973426e12ea5c6a16d4413b15
-rw-r--r--Changes8
-rw-r--r--MANIFEST1
-rw-r--r--MANIFEST.SKIP1
-rw-r--r--META.json4
-rw-r--r--META.yml4
-rw-r--r--README14
-rw-r--r--examples/json-tiny-round-trip-demo.pl24
-rw-r--r--lib/JSON/Parse.pm16
-rw-r--r--lib/JSON/Parse.pod1647
-rw-r--r--lib/JSON/Tokenize.pm2
-rw-r--r--lib/JSON/Tokenize.pod4
-rw-r--r--see-also-info.json499
-rw-r--r--t/bugzilla-2049.t6
-rw-r--r--t/read-file.t4
-rwxr-xr-xt/string-bug-44.t4
-rw-r--r--t/syntax.t4
16 files changed, 1652 insertions, 590 deletions
diff --git a/Changes b/Changes
index 3d1f46d..ea8e52b 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,11 @@
+0.59 2021-01-04
+
+* "json_file_to_perl" renamed "read_json"
+* Documentation work
+ -- Benchmarks section updated with latest versions, add Cpanel::JSON::XS
+ -- Add Metacpan vote ratings to other CPAN modules section
+ -- Sections reordered to put methods above parsing details
+
0.58 2021-01-01
* Protect against stack overflows by having maximum parsing depth
diff --git a/MANIFEST b/MANIFEST
index 27a759d..dc2a250 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -33,6 +33,7 @@ MANIFEST This list of files
MANIFEST.SKIP
README
script/validjson
+see-also-info.json
t/array.t
t/bugzilla-2049.t
t/collision.t
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index 215ee1b..3289b0b 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -56,6 +56,7 @@ benchmarks
^versionup\.pl$
# CI control files
^\.travis\.yml$
+^build/.*$
# Local variables:
# comment-start: "#"
# End:
diff --git a/META.json b/META.json
index bb1b0fb..532276a 100644
--- a/META.json
+++ b/META.json
@@ -1,5 +1,5 @@
{
- "abstract" : "Read JSON into a Perl variable",
+ "abstract" : "Parse JSON",
"author" : [
"Ben Bullock <bkb@cpan.org>"
],
@@ -48,6 +48,6 @@
"web" : "https://github.com/benkasminbullock/JSON-Parse"
}
},
- "version" : "0.58",
+ "version" : "0.59",
"x_serialization_backend" : "JSON::PP version 4.04"
}
diff --git a/META.yml b/META.yml
index ad31e52..e7b0d0e 100644
--- a/META.yml
+++ b/META.yml
@@ -1,5 +1,5 @@
---
-abstract: 'Read JSON into a Perl variable'
+abstract: 'Parse JSON'
author:
- 'Ben Bullock <bkb@cpan.org>'
build_requires:
@@ -23,5 +23,5 @@ requires:
resources:
bugtracker: https://github.com/benkasminbullock/JSON-Parse/issues
repository: git://github.com/benkasminbullock/JSON-Parse.git
-version: '0.58'
+version: '0.59'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff --git a/README b/README
index c10aaaa..8350131 100644
--- a/README
+++ b/README
@@ -6,7 +6,7 @@
-This is the README for JSON::Parse version 0.58.
+This is the README for JSON::Parse version 0.59.
JSON::Parse is a "module" for the Perl computer programming language, a
library of computer code to install on a computer. This document contains
@@ -24,7 +24,7 @@ four sections:
1. ABOUT
-JSON::Parse - Read JSON into a Perl variable
+JSON::Parse - Parse JSON
A module for parsing JSON. (JSON means "JavaScript Object Notation"
and it is specified in "RFC 8259".)
@@ -34,7 +34,7 @@ containing JSON, and returns an equivalent Perl structure. It also
offers validation of JSON via "valid_json", which returns true or
false depending on whether the JSON is correct or not, and
"assert_valid_json", which produces a descriptive fatal error if the
-JSON is invalid. A function "json_file_to_perl" reads JSON from a
+JSON is invalid. A function "read_json" reads JSON from a
file, and there is a safer version of "parse_json" called
"parse_json_safe" which doesn't throw exceptions.
@@ -75,11 +75,11 @@ If you have the App::cpanminus installer, you may prefer
cpanm JSON::Parse
-To install the module from the source file, JSON-Parse-0.58.tar.gz, follow
+To install the module from the source file, JSON-Parse-0.59.tar.gz, follow
this sequence of commands:
- tar xfz JSON-Parse-0.58.tar.gz
- cd JSON-Parse-0.58
+ tar xfz JSON-Parse-0.59.tar.gz
+ cd JSON-Parse-0.59
perl Makefile.PL
make
make install
@@ -104,6 +104,6 @@ repository on github at
-----------------------------------------------------------------------------
-This README was written on Fri Jan 1 10:00:07 2021.
+This README was written on Mon Jan 4 08:47:42 2021.
-----------------------------------------------------------------------------
diff --git a/examples/json-tiny-round-trip-demo.pl b/examples/json-tiny-round-trip-demo.pl
index 9c8e3a5..99747e6 100644
--- a/examples/json-tiny-round-trip-demo.pl
+++ b/examples/json-tiny-round-trip-demo.pl
@@ -1,25 +1,35 @@
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
-use JSON::Tiny '0.54', qw(decode_json encode_json);
+use utf8;
+use JSON::Tiny '0.58', qw(decode_json encode_json);
use JSON::Parse;
use JSON::Create;
-my $cream = '{"clapton":true,"hendrix":false,"bruce":true,"fripp":false}';
+binmode STDOUT, ":encoding(utf8)";
+my $cream = '{"clapton":true,"hendrix":false}';
my $jp = JSON::Parse->new ();
-my $jc = JSON::Create->new ();
+my $jc = JSON::Create->new (sort => 1);
+
print "First do a round-trip of our modules:\n\n";
print $jc->run ($jp->run ($cream)), "\n\n";
+
print "Now do a round-trip of JSON::Tiny:\n\n";
print encode_json (decode_json ($cream)), "\n\n";
-print "First, incompatible mode:\n\n";
+
+print "🥴 First, incompatible mode:\n\n";
print 'tiny(parse): ', encode_json ($jp->run ($cream)), "\n";
print 'create(tiny): ', $jc->run (decode_json ($cream)), "\n\n";
+
+# Set our parser to produce these things as literals:
$jp->set_true (JSON::Tiny::true);
$jp->set_false (JSON::Tiny::false);
-print "Compatibility with JSON::Parse:\n\n";
+
+print "🔄 Compatibility with JSON::Parse:\n\n";
print 'tiny(parse):', encode_json ($jp->run ($cream)), "\n\n";
$jc->bool ('JSON::Tiny::_Bool');
-print "Compatibility with JSON::Create:\n\n";
+
+print "🔄 Compatibility with JSON::Create:\n\n";
print 'create(tiny):', $jc->run (decode_json ($cream)), "\n\n";
-print "JSON::Parse and JSON::Create are still compatible too:\n\n";
+
+print "🔄 JSON::Parse and JSON::Create are still compatible too:\n\n";
print $jc->run ($jp->run ($cream)), "\n";
diff --git a/lib/JSON/Parse.pm b/lib/JSON/Parse.pm
index 7e5269e..f427733 100644
--- a/lib/JSON/Parse.pm
+++ b/lib/JSON/Parse.pm
@@ -7,6 +7,7 @@ require Exporter;
json_to_perl
parse_json
parse_json_safe
+ read_json
valid_json
validate_json
/;
@@ -17,7 +18,7 @@ require Exporter;
use warnings;
use strict;
use Carp;
-our $VERSION = '0.58';
+our $VERSION = '0.59';
require XSLoader;
XSLoader::load (__PACKAGE__, $VERSION);
@@ -64,19 +65,22 @@ sub validate_json
goto &assert_valid_json;
}
+sub read_json
+{
+ goto &json_file_to_perl;
+}
+
sub valid_json
{
my ($json) = @_;
if (! $json) {
return 0;
}
- eval {
+ my $ok = eval {
assert_valid_json (@_);
+ 1;
};
- if ($@) {
- return 0;
- }
- return 1;
+ return $ok;
}
sub json_file_to_perl
diff --git a/lib/JSON/Parse.pod b/lib/JSON/Parse.pod
index f962dee..a006a08 100644
--- a/lib/JSON/Parse.pod
+++ b/lib/JSON/Parse.pod
@@ -7,7 +7,7 @@
=head1 NAME
-JSON::Parse - Read JSON into a Perl variable
+JSON::Parse - Parse JSON
=head1 SYNOPSIS
@@ -23,8 +23,8 @@ Convert JSON into Perl.
=head1 VERSION
-This documents version 0.58 of JSON::Parse corresponding to
-L<git commit 6df355c947edf0bf190c0f3631ea46e65d4bb7ed|https://github.com/benkasminbullock/JSON-Parse/commit/6df355c947edf0bf190c0f3631ea46e65d4bb7ed> released on Fri Jan 1 09:59:25 2021 +0900.
+This documents version 0.59 of JSON::Parse corresponding to
+L<git commit e10440285845d6b0f29746bce84c6b546e557f6f|https://github.com/benkasminbullock/JSON-Parse/commit/e10440285845d6b0f29746bce84c6b546e557f6f> released on Mon Jan 4 08:46:00 2021 +0900.
@@ -38,7 +38,7 @@ containing JSON, and returns an equivalent Perl structure. It also
offers validation of JSON via L</valid_json>, which returns true or
false depending on whether the JSON is correct or not, and
L</assert_valid_json>, which produces a descriptive fatal error if the
-JSON is invalid. A function L</json_file_to_perl> reads JSON from a
+JSON is invalid. A function L</read_json> reads JSON from a
file, and there is a safer version of L</parse_json> called
L</parse_json_safe> which doesn't throw exceptions.
@@ -51,6 +51,40 @@ L</Handling of Unicode>.
=head1 FUNCTIONS
+=head2 assert_valid_json
+
+
+ use JSON::Parse 'assert_valid_json';
+ eval {
+ assert_valid_json ('["xyz":"b"]');
+ };
+ if ($@) {
+ print "Your JSON was invalid: $@\n";
+ }
+ # Prints "Unexpected character ':' parsing array"
+
+
+produces output
+
+ Your JSON was invalid: JSON error at line 1, byte 7/11: Unexpected character ':' parsing array starting from byte 1: expecting whitespace: '\n', '\r', '\t', ' ' or comma: ',' or end of array: ']' at /usr/home/ben/projects/Json3/examples/assert.pl line 6.
+
+
+
+(This example is included as L<F<assert.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/assert.pl> in the distribution.)
+
+
+This is the underlying function for L</valid_json>. It runs at the
+same speed, but it throws an error if the JSON is wrong, rather than
+returning 1 or 0. See L</DIAGNOSTICS> for the error format, which is
+identical to L</parse_json>.
+
+This cannot detect key collisions in the JSON since it does not store
+values. See L</Key collisions> for more on this module's handling of
+non-unique names in the JSON.
+
+The behaviour of disallowing empty inputs was changed in version
+0.49.
+
=head2 parse_json
use JSON::Parse 'parse_json';
@@ -79,7 +113,7 @@ produces output
HASH
-(This example is included as L<F<hash.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/hash.pl> in the distribution.)
+(This example is included as L<F<hash.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/hash.pl> in the distribution.)
If the input JSON text is a serialized array, an array reference is
@@ -97,7 +131,7 @@ produces output
ARRAY
-(This example is included as L<F<array.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/array.pl> in the distribution.)
+(This example is included as L<F<array.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/array.pl> in the distribution.)
Otherwise a Perl scalar is returned.
@@ -105,15 +139,60 @@ Otherwise a Perl scalar is returned.
The behaviour of allowing a scalar was added in version 0.32 of this
module. This brings it into line with the new specification for
JSON. The behaviour of disallowing empty inputs was changed in version
-0.49. This makes it conform to the L</JSON Parsing Test Suite>.
+0.49.
The function L</parse_json_safe> offers a version of this function
with various safety features enabled.
-=head2 json_file_to_perl
+=head2 parse_json_safe
+
+This is almost the same thing as L</parse_json>, but has the following
+differences:
+
+=over
+
+=item Does not throw exceptions
+
+If the JSON is invalid, a warning is printed and the undefined value
+is returned, as if calling L</parse_json> like this:
+
+ eval {
+ $out = parse_json ($json);
+ };
+ if ($@) {
+ carp $@;
+ $out = undef;
+ }
+
+=item Detects key collisions
+
+This switches on L</detect_collisions>, so that if the JSON contains
+non-unique names, a warning is printed and the undefined value is
+returned. See L</Key collisions> for an explanation of what a key
+collision is.
+
+=item Booleans are not read-only
+
+This switches on L</copy_literals> so that JSON true, false and null
+values are copied. These values can be modified, but they will not be
+converted back into C<true> and C<false> by L<JSON::Create>.
+
+=item Errors are reported by carp
+
+Parsing errors are reported by L<Carp/carp>, so the error line number
+refers to the caller's line.
+
+=back
+
+As the name implies, this is meant to be a "safety-first" version of
+L</parse_json>.
+
+🎲 This function was added in version 0.38.
+
+=head2 read_json
- use JSON::Parse 'json_file_to_perl';
- my $p = json_file_to_perl ('filename');
+ use JSON::Parse 'read_json';
+ my $p = read_json ('filename');
This is exactly the same as L</parse_json> except that it reads the
JSON from the specified file rather than a scalar. The file must be in
@@ -124,6 +203,9 @@ details). The output is marked as character strings.
This is a convenience function written in Perl. You may prefer to read
the file yourself using another module if you need faster performance.
+This was renamed from L</json_file_to_perl> in version 0.59. The old
+name will also continue to work indefinitely.
+
=head2 valid_json
use JSON::Parse 'valid_json';
@@ -143,85 +225,337 @@ This cannot detect key collisions in the JSON since it does not store
values. See L</Key collisions> for more on this module's handling of
non-unique names in the JSON.
-=head2 assert_valid_json
+=head1 METHODS
+
+If you need to parse JSON and you are not satisfied with the parsing
+options offered by L</parse_json> and L</parse_json_safe>, you can
+create a JSON parsing object with L</new> and set various options on
+the object, then use it with L</run>. These options include the
+ability to copy JSON literals with L</copy_literals>, switch off fatal
+errors with L</warn_only>, detect key collisions in objects with
+L</detect_collisions>, and set the JSON literals to user defined
+values with the methods described under L</Methods for manipulating
+literals>.
+
+These methods only work on an object created with L</new>; they do not
+affect the behaviour of L</parse_json> or L</parse_json_safe>.
+
+=head2 check
+
+ eval {
+ $jp->check ($json);
+ };
+
+This does the same thing as L</assert_valid_json>, except its
+behaviour can be modified using the L</diagnostics_hash> method.
+
+🎲 This method was added in version 0.48. This is for the benefit of
+L<JSON::Repair>.
+
+=head2 copy_literals
+
+ $jp->copy_literals (1);
+
+With a true value, copy JSON literal values (C<null>, C<true>, and
+C<false>) into new Perl scalar values, and don't put read-only values
+into the output.
+
+With a false value, use read-only scalars:
+
+ $jp->copy_literals (0);
+
+The C<copy_literals (1)> behaviour is the behaviour of
+L</parse_json_safe>. The C<copy_literals (0)> behaviour is the
+behaviour of L</parse_json>.
+
+If the user also sets user-defined literals with L</set_true>,
+L</set_false> and L</set_null>, that takes precedence over this.
+
+🎲 This method was added in version 0.38.
+
+=head2 detect_collisions
+
+ $jp->detect_collisions (1);
+
+This switches on a check for hash key collisions (non-unique names in
+JSON objects). If a collision is found, an error message L</Name is
+not unique> is printed, which also gives the non-unique name and the
+byte position where the start of the colliding string was found:
- use JSON::Parse 'assert_valid_json';
+ use JSON::Parse;
+ my $jp = JSON::Parse->new ();
+ $jp->detect_collisions (1);
eval {
- assert_valid_json ('["xyz":"b"]');
+ $jp->run ('{"animals":{"cat":"moggy","cat":"feline","cat":"neko"}}');
};
- if ($@) {
- print "Your JSON was invalid: $@\n";
- }
- # Prints "Unexpected character ':' parsing array"
+ print "$@\n" if $@;
produces output
- Your JSON was invalid: JSON error at line 1, byte 7/11: Unexpected character ':' parsing array starting from byte 1: expecting whitespace: '\n', '\r', '\t', ' ' or comma: ',' or end of array: ']' at /usr/home/ben/projects/Json3/examples/assert.pl line 6.
+ JSON error at line 1, byte 28/55: Name is not unique: "cat" parsing object starting from byte 12 at /usr/home/ben/projects/Json3/blib/lib/JSON/Parse.pm line 103.
-(This example is included as L<F<assert.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/assert.pl> in the distribution.)
+(This example is included as L<F<collide.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/collide.pl> in the distribution.)
-This is the underlying function for L</valid_json>. It runs at the
-same speed, but it throws an error if the JSON is wrong, rather than
-returning 1 or 0. See L</DIAGNOSTICS> for the error format, which is
-identical to L</parse_json>.
+The C<detect_collisions (1)> behaviour is the behaviour of
+L</parse_json_safe>. The C<detect_collisions (0)> behaviour is the
+behaviour of L</parse_json>.
-This cannot detect key collisions in the JSON since it does not store
-values. See L</Key collisions> for more on this module's handling of
-non-unique names in the JSON.
+🎲 This method was added in version 0.38.
-The behaviour of disallowing empty inputs was changed in version
-0.49. This makes it conform to the L</JSON Parsing Test Suite>, and
-also makes it give identical results to L</valid_json>.
+=head2 diagnostics_hash
-=head2 parse_json_safe
+ $jp->diagnostics_hash (1);
-This is almost the same thing as L</parse_json>, but has the following
-differences:
+This changes diagnostics produced by errors from a simple string into
+a hash reference containing various fields. This is experimental and
+subject to change. This is incompatible with L</warn_only>.
-=over
+This replaces the previous experimental global variable
+C<$json_diagnostics>, which was removed from the module. The hash keys
+and values are identical to those provided in the object returned by
+C<$json_diagnostics>, with the addition of a key C<error as string>
+which returns the usual error.
-=item Does not throw exceptions
+This requires Perl version 5.14 or later.
-If the JSON is invalid, a warning is printed and the undefined value
-is returned, as if calling L</parse_json> like this:
+🎲 This method was added in version 0.46.
- eval {
- $out = parse_json ($json);
- };
- if ($@) {
- carp $@;
- $out = undef;
- }
+=head2 get_max_depth
-=item Detects key collisions
+ my $max_depth = $jp->get_max_depth ();
-This switches on L</detect_collisions>, so that if the JSON contains
-non-unique names, a warning is printed and the undefined value is
-returned. See L</Key collisions> for an explanation of what a key
-collision is.
+This returns the maximum nesting depth of objects or arrays in the
+input JSON. The default value is 10,000.
-=item Booleans are not read-only
+🎲 This method was added in version 0.58.
-This switches on L</copy_literals> so that JSON true, false and null
-values are copied. These values can be modified, but they will not be
-converted back into C<true> and C<false> by L<JSON::Create>.
+=head2 new
-=item Errors are reported by carp
+ my $jp = JSON::Parse->new ();
-Parsing errors are reported by L<Carp/carp>, so the error line number
-refers to the caller's line.
+Create a new JSON::Parse object.
-=back
+🎲 This method was added in version 0.38.
-As the name implies, this is meant to be a "safety-first" version of
-L</parse_json>.
+=head2 run
+
+ my $out = $jp->run ($json);
+
+This does the same thing as L</parse_json>, except its behaviour can
+be modified using the methods below.
+
+🎲 This method was added in version 0.38.
+
+=head2 set_max_depth
+
+ $jp->set_max_depth (42);
+
+Set the maximum nesting depth of objects or arrays in the input
+JSON. The default value is 10,000.
+
+🎲 This method was added in version 0.58.
+
+=head2 warn_only
+
+ $jp->warn_only (1);
+
+Warn, don't die, on error. Failed parsing returns the undefined value,
+C<undef>, and prints a warning.
+
+This can be switched off again using any false value:
+
+ $jp->warn_only ('');
+
+🎲 This method was added in version 0.41.
+
+=head2 Methods for manipulating literals
+
+These methods alter what is written into the Perl structure when the
+parser sees a literal value, C<true>, C<false> or C<null> in the input
+JSON.
+
+This number of methods is needed because of the possibility that a
+user wants to set the output for C<false> to be C<undef>:
+
+ $jp->set_false (undef);
+
+Thus, we cannot use a single function C<< $jp->false (undef) >> to
+cover both setting and deleting of values.
+
+🎲 This facility was added in version 0.38.
+
+
+
+
+
+=head3 set_true
+
+ $jp->set_true ("Yes, that is so true");
-This function was added in version 0.38.
+Supply a scalar to be used in place of the JSON C<true> literal.
+
+This example puts the string "Yes, that is so true" into the hash or
+array when we hit a "true" literal, rather than the default read-only
+scalar:
+
+
+ use JSON::Parse;
+ my $json = '{"yes":true,"no":false}';
+ my $jp = JSON::Parse->new ();
+ $jp->set_true ('Yes, that is so true');
+ my $out = $jp->run ($json);
+ print $out->{yes}, "\n";
+
+
+
+prints
+
+ Yes, that is so true
+
+
+
+To override the previous value, call it again with a new value. To
+delete the value and revert to the default behaviour, use
+L</delete_true>.
+
+
+
+If you give this a value which is not "true", as in Perl will
+evaluate it as a false in an if statement, it prints a warning
+L</User-defined value for JSON true evaluates as false>.
+You can switch this warning off with L</no_warn_literals>.
+
+
+
+🎲 This method was added in version 0.38.
+
+=head3 delete_true
+
+ $jp->delete_true ();
+
+Delete the user-defined true value. See L</set_true>.
+
+This method is "safe" in that it has absolutely no effect if no
+user-defined value is in place. It does not return a value.
+
+🎲 This method was added in version 0.38.
+
+
+
+
+=head3 set_false
+
+ $jp->set_false (JSON::PP::Boolean::false);
+
+Supply a scalar to be used in place of the JSON C<false> literal.
+
+In the above example, when we hit a "false" literal, we put
+C<JSON::PP::Boolean::false> in the output, similar to L<JSON::PP> and
+other CPAN modules like L<Mojo::JSON> or L<JSON::XS>.
+
+
+To override the previous value, call it again with a new value. To
+delete the value and revert to the default behaviour, use
+L</delete_false>.
+
+
+
+If you give this a value which is not "false", as in Perl will
+evaluate it as a false in an if statement, it prints a warning
+L</User-defined value for JSON false evaluates as true>.
+You can switch this warning off with L</no_warn_literals>.
+
+
+
+🎲 This method was added in version 0.38.
+
+=head3 delete_false
+
+ $jp->delete_false ();
+
+Delete the user-defined false value. See L</set_false>.
+
+This method is "safe" in that it has absolutely no effect if no
+user-defined value is in place. It does not return a value.
+
+🎲 This method was added in version 0.38.
+
+
+
+
+=head3 set_null
+
+ $jp->set_null (0);
+
+Supply a scalar to be used in place of the JSON C<null> literal.
+
+
+To override the previous value, call it again with a new value. To
+delete the value and revert to the default behaviour, use
+L</delete_null>.
+
+
+
+🎲 This method was added in version 0.38.
+
+=head3 delete_null
+
+ $jp->delete_null ();
+
+Delete the user-defined null value. See L</set_null>.
+
+This method is "safe" in that it has absolutely no effect if no
+user-defined value is in place. It does not return a value.
+
+🎲 This method was added in version 0.38.
+
+
+
+=head3 no_warn_literals
+
+ $jp->no_warn_literals (1);
+
+Use a true value to switch off warnings about setting boolean values
+to contradictory things. For example if you want to set the JSON
+C<false> literal to turn into the string "false",
+
+ $jp->no_warn_literals (1);
+ $jp->set_false ("false");
+
+See also L</Contradictory values for "true" and "false">.
+
+This also switches off the warning L</User-defined value overrules
+copy_literals>.
+
+🎲 This method was added in version 0.38.
+
+=head1 OLD INTERFACE
+
+The following alternative function names are accepted. These are the
+names used for the functions in old versions of this module. These
+names are not deprecated and will never be removed from the module.
+
+The names ending in "_to_perl" seem quite silly in retrospect since
+surely it is obvious that one is programming in Perl.
+
+=head2 json_to_perl
+
+This is exactly the same function as L</parse_json>.
+
+=head2 json_file_to_perl
+
+This is exactly the same function as L</read_json>. The function was
+renamed in version 0.59, after the same function in
+L</File::JSON::Slurper>.
+
+=head2 validate_json
+
+This is exactly the same function as L</assert_valid_json>.
=head1 Mapping from JSON to Perl
@@ -354,7 +688,7 @@ produces output
Native Perl: かあ
-(This example is included as L<F<unicode-details.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/unicode-details.pl> in the distribution.)
+(This example is included as L<F<unicode-details.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/unicode-details.pl> in the distribution.)
Although in general the above would be an unsafe practice, JSON::Parse
@@ -427,7 +761,7 @@ produces output
Ambiguous key 'a' is 2
-(This example is included as L<F<key-collision.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/key-collision.pl> in the distribution.)
+(This example is included as L<F<key-collision.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/key-collision.pl> in the distribution.)
Here the key "a" could be either 1 or 2. As seen in the example,
@@ -488,31 +822,42 @@ other CPAN modules, create a JSON::Parse object with L</new>, and set
JSON::Parse's literals with L</set_true>, L</set_false>, and
L</set_null>.
-This example demonstrates round-trip compatibility using L<JSON::Tiny>
-version 0.54:
+=head3 A round trip with JSON::Tiny
+
+This example demonstrates round-trip compatibility using L<JSON::Tiny>,
+version 0.58:
- use JSON::Tiny '0.54', qw(decode_json encode_json);
+ use utf8;
+ use JSON::Tiny '0.58', qw(decode_json encode_json);
use JSON::Parse;
use JSON::Create;
- my $cream = '{"clapton":true,"hendrix":false,"bruce":true,"fripp":false}';
+ my $cream = '{"clapton":true,"hendrix":false}';
my $jp = JSON::Parse->new ();
- my $jc = JSON::Create->new ();
+ my $jc = JSON::Create->new (sort => 1);
+
print "First do a round-trip of our modules:\n\n";
print $jc->run ($jp->run ($cream)), "\n\n";
+
print "Now do a round-trip of JSON::Tiny:\n\n";
print encode_json (decode_json ($cream)), "\n\n";
- print "First, incompatible mode:\n\n";
+
+ print "🥴 First, incompatible mode:\n\n";
print 'tiny(parse): ', encode_json ($jp->run ($cream)), "\n";
print 'create(tiny): ', $jc->run (decode_json ($cream)), "\n\n";
+
+ # Set our parser to produce these things as literals:
$jp->set_true (JSON::Tiny::true);
$jp->set_false (JSON::Tiny::false);
- print "Compatibility with JSON::Parse:\n\n";
+
+ print "🔄 Compatibility with JSON::Parse:\n\n";
print 'tiny(parse):', encode_json ($jp->run ($cream)), "\n\n";
$jc->bool ('JSON::Tiny::_Bool');
- print "Compatibility with JSON::Create:\n\n";
+
+ print "🔄 Compatibility with JSON::Create:\n\n";
print 'create(tiny):', $jc->run (decode_json ($cream)), "\n\n";
- print "JSON::Parse and JSON::Create are still compatible too:\n\n";
+
+ print "🔄 JSON::Parse and JSON::Create are still compatible too:\n\n";
print $jc->run ($jp->run ($cream)), "\n";
@@ -520,31 +865,31 @@ produces output
First do a round-trip of our modules:
- {"hendrix":false,"clapton":true,"fripp":false,"bruce":true}
+ {"clapton":true,"hendrix":false}
Now do a round-trip of JSON::Tiny:
- {"bruce":true,"clapton":true,"fripp":false,"hendrix":false}
+ {"clapton":true,"hendrix":false}
- First, incompatible mode:
+ 🥴 First, incompatible mode:
- tiny(parse): {"bruce":1,"clapton":1,"fripp":"","hendrix":""}
- create(tiny): {"fripp":0,"bruce":1,"clapton":1,"hendrix":0}
+ tiny(parse): {"clapton":1,"hendrix":""}
+ create(tiny): {"clapton":1,"hendrix":0}
- Compatibility with JSON::Parse:
+ 🔄 Compatibility with JSON::Parse:
- tiny(parse):{"bruce":true,"clapton":true,"fripp":false,"hendrix":false}
+ tiny(parse):{"clapton":true,"hendrix":false}
- Compatibility with JSON::Create:
+ 🔄 Compatibility with JSON::Create:
- create(tiny):{"hendrix":false,"fripp":false,"bruce":true,"clapton":true}
+ create(tiny):{"clapton":true,"hendrix":false}
- JSON::Parse and JSON::Create are still compatible too:
+ 🔄 JSON::Parse and JSON::Create are still compatible too:
- {"fripp":false,"bruce":true,"clapton":true,"hendrix":false}
+ {"clapton":true,"hendrix":false}
-(This example is included as L<F<json-tiny-round-trip-demo.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/json-tiny-round-trip-demo.pl> in the distribution.)
+(This example is included as L<F<json-tiny-round-trip-demo.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.59/examples/json-tiny-round-trip-demo.pl> in the distribution.)
Most of the other CPAN modules use similar methods to L<JSON::Tiny>,
@@ -592,329 +937,6 @@ read-only scalars, so
produces no error. This is because Perl copies the scalar.
-=head1 METHODS
-
-If you need to parse JSON and you are not satisfied with the parsing
-options offered by L</parse_json> and L</parse_json_safe>, you can
-create a JSON parsing object with L</new> and set various options on
-the object, then use it with L</run>. These options include the
-ability to copy JSON literals with L</copy_literals>, switch off fatal
-errors with L</warn_only>, detect key collisions in objects with
-L</detect_collisions>, and set the JSON literals to user defined
-values with the methods described under L</Methods for manipulating
-literals>.
-
-These methods only work on an object created with L</new>; they do not
-affect the behaviour of L</parse_json> or L</parse_json_safe>.
-
-=head2 check
-
- eval {
- $jp->check ($json);
- };
-
-This does the same thing as L</assert_valid_json>, except its
-behaviour can be modified using the methods below. Only the
-L</diagnostics_hash> method will actually affect this.
-
-This method was added in version 0.48, for the benefit of
-L<JSON::Repair>.
-
-=head2 copy_literals
-
- $jp->copy_literals (1);
-
-With a true value, copy JSON literal values (C<null>, C<true>, and
-C<false>) into new Perl scalar values, and don't put read-only values
-into the output.
-
-With a false value, use read-only scalars:
-
- $jp->copy_literals (0);
-
-The C<copy_literals (1)> behaviour is the behaviour of
-L</parse_json_safe>. The C<copy_literals (0)> behaviour is the
-behaviour of L</parse_json>.
-
-If the user also sets user-defined literals with L</set_true>,
-L</set_false> and L</set_null>, that takes precedence over this.
-
-This method was added in version 0.38.
-
-=head2 detect_collisions
-
- $jp->detect_collisions (1);
-
-This switches on a check for hash key collisions (non-unique names in
-JSON objects). If a collision is found, an error message L</Name is
-not unique> is printed, which also gives the non-unique name and the
-byte position where the start of the colliding string was found:
-
-
- use JSON::Parse;
- my $jp = JSON::Parse->new ();
- $jp->detect_collisions (1);
- eval {
- $jp->run ('{"animals":{"cat":"moggy","cat":"feline","cat":"neko"}}');
- };
- print "$@\n" if $@;
-
-
-produces output
-
- JSON error at line 1, byte 28/55: Name is not unique: "cat" parsing object starting from byte 12 at /usr/home/ben/projects/Json3/blib/lib/JSON/Parse.pm line 103.
-
-
-
-(This example is included as L<F<collide.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.58/examples/collide.pl> in the distribution.)
-
-
-The C<detect_collisions (1)> behaviour is the behaviour of
-L</parse_json_safe>. The C<detect_collisions (0)> behaviour is the
-behaviour of L</parse_json>.
-
-This method was added in version 0.38.
-
-=head2 diagnostics_hash
-
- $jp->diagnostics_hash (1);
-
-This changes diagnostics produced by errors from a simple string into
-a hash reference containing various fields. This is experimental and
-subject to change. This is incompatible with L</warn_only>.
-
-This replaces the previous experimental global variable
-C<$json_diagnostics>, which was removed from the module. The hash keys
-and values are identical to those provided in the object returned by
-C<$json_diagnostics>, with the addition of a key C<error as string>
-which returns the usual error.
-
-This requires Perl version 5.14 or later.
-
-This method was added in version 0.46.
-
-=head2 get_max_depth
-
- my $max_depth = $jp->get_max_depth ();
-
-This returns the maximum nesting depth of objects or arrays in the
-input JSON. The default value is 10,000.
-
-=head2 new
-
- my $jp = JSON::Parse->new ();
-
-Create a new JSON::Parse object.
-
-This method was added in version 0.38.
-
-=head2 run
-
- my $out = $jp->run ($json);
-
-This does the same thing as L</parse_json>, except its behaviour can
-be modified using the methods below.
-
-This method was added in version 0.38.
-
-
-=head2 set_max_depth
-
- $jp->set_max_depth (42);
-
-Set the maximum nesting depth of objects or arrays in the input
-JSON. The default value is 10,000.
-
-=head2 warn_only
-
- $jp->warn_only (1);
-
-Warn, don't die, on error. Failed parsing returns the undefined value,
-C<undef>, and prints a warning.
-
-This can be switched off again using any false value:
-
- $jp->warn_only ('');
-
-This method was documented in version 0.38, but only implemented in
-version 0.41.
-
-=head2 Methods for manipulating literals
-
-These methods alter what is written into the Perl structure when the
-parser sees a literal value, C<true>, C<false> or C<null> in the input
-JSON.
-
-This number of methods is unfortunately necessary, since it's possible
-that a user might want to set_false (undef) to set false values to
-turn into undefs.
-
- $jp->set_false (undef);
-
-Thus, we cannot use a single function C<< $jp->false (undef) >> to
-cover both setting and deleting of values.
-
-These methods were added in version 0.38.
-
-
-
-
-
-=head3 set_true
-
- $jp->set_true ("Yes, that is so true");
-
-Supply a scalar to be used in place of the JSON C<true> literal.
-
-This example puts the string "Yes, that is so true" into the hash or
-array when we hit a "true" literal, rather than the default read-only
-scalar:
-
-
- use JSON::Parse;
- my $json = '{"yes":true,"no":false}';
- my $jp = JSON::Parse->new ();
- $jp->set_true ('Yes, that is so true');
- my $out = $jp->run ($json);
- print $out->{yes}, "\n";
-
-
-
-prints
-
- Yes, that is so true
-
-
-
-To override the previous value, call it again with a new value. To
-delete the value and revert to the default behaviour, use
-L</delete_true>.
-
-
-
-If you give this a value which is not "true", as in Perl will
-evaluate it as a false in an if statement, it prints a warning
-L</User-defined value for JSON true evaluates as false>.
-You can switch this warning off with L</no_warn_literals>.
-
-
-
-This method was added in version 0.38.
-
-=head3 delete_true
-
- $jp->delete_true ();
-
-Delete the user-defined true value. See L</set_true>.
-
-This method is "safe" in that it has absolutely no effect if no
-user-defined value is in place. It does not return a value.
-
-This method was added in version 0.38.
-
-
-
-
-=head3 set_false
-
- $jp->set_false (JSON::PP::Boolean::false);
-
-Supply a scalar to be used in place of the JSON C<false> literal.
-
-In the above example, when we hit a "false" literal, we put
-C<JSON::PP::Boolean::false> in the output, similar to L<JSON::PP> and
-other CPAN modules like L<Mojo::JSON> or L<JSON::XS>.
-
-
-To override the previous value, call it again with a new value. To
-delete the value and revert to the default behaviour, use
-L</delete_false>.
-
-
-
-If you give this a value which is not "false", as in Perl will
-evaluate it as a false in an if statement, it prints a warning
-L</User-defined value for JSON false evaluates as true>.
-You can switch this warning off with L</no_warn_literals>.
-
-
-
-This method was added in version 0.38.
-
-=head3 delete_false
-
- $jp->delete_false ();
-
-Delete the user-defined false value. See L</set_false>.
-
-This method is "safe" in that it has absolutely no effect if no
-user-defined value is in place. It does not return a value.
-
-This method was added in version 0.38.
-
-
-
-
-=head3 set_null
-
- $jp->set_null (0);
-
-Supply a scalar to be used in place of the JSON C<null> literal.
-
-
-To override the previous value, call it again with a new value. To
-delete the value and revert to the default behaviour, use
-L</delete_null>.
-
-
-
-This method was added in version 0.38.
-
-=head3 delete_null
-
- $jp->delete_null ();
-
-Delete the user-defined null value. See L</set_null>.
-
-This method is "safe" in that it has absolutely no effect if no
-user-defined value is in place. It does not return a value.
-
-This method was added in version 0.38.
-
-
-
-=head3 no_warn_literals
-
- $jp->no_warn_literals (1);
-
-Use a true value to switch off warnings about setting boolean values
-to contradictory things. For example if you want to set the JSON
-C<false> literal to turn into the string "false",
-
- $jp->no_warn_literals (1);
- $jp->set_false ("false");
-
-See also L</Contradictory values for "true" and "false">.
-
-This also switches off the warning L</User-defined value overrules
-copy_literals>.
-
-This method was added in version 0.38.
-
-=head1 OLD INTERFACE
-
-The following alternative function names are accepted. These are the
-names used for the functions in old versions of this module. These
-names are not deprecated and will never be removed from the module.
-
-=head2 json_to_perl
-
-This is exactly the same function as L</parse_json>.
-
-=head2 validate_json
-
-This is exactly the same function as L</assert_valid_json>.
-
=head1 RESTRICTIONS
This module imposes the following restrictions on its input.
@@ -930,15 +952,19 @@ JSON::Parse does not accept single quotes (') instead of double quotes
accept control characters (0x00 - 0x1F) in strings, missing commas
between array or hash elements like C<["a" "b"]>, or trailing commas
like C<["a","b","c",]>. It also does not accept trailing
-non-whitespace, like the second "]" in C<["a"]]>.
+non-whitespace, like the second "]" in C<["a"]]>.
+
+You may find L</JSON::Repair> by the same authors as JSON::Parse
+useful if you need to process JSON-like text with tolerance for
+errors.
=item No incremental parsing
JSON::Parse does not parse incrementally. It only parses fully-formed
JSON strings which include all opening and closing brackets. This is
an inherent part of the design of the module. Incremental parsing in
-the style of L<XML::Parser> would (obviously) require some kind of
-callback structure to deal with the elements of the partially digested
+the style of L<XML::Parser> would require some kind of callback
+structure to deal with the elements of the partially digested
structures, but JSON::Parse was never designed to do this; it merely
converts what it sees into a Perl structure. Claims to offer
incremental JSON parsing in other modules' documentation should be
@@ -960,16 +986,21 @@ L<perluniintro>):
open my $input, "<:encoding(UTF-16)", 'some-json-file';
-JSON::Parse does not determine the nature of the octet stream, as
-described in part 3 of L</RFC 8259>.
+JSON::Parse does not try to determine the nature of the octet stream
+using BOM markers. A BOM marker in the input consists of bytes C<0xFE>
+and C<0xFF> which are invalid as UTF-8, and thus will cause a fatal
+error.
This restriction to UTF-8 applies regardless of whether Perl thinks
that the input string is a character string or a byte
string. Non-UTF-8 input will cause an L</Unexpected character> error.
-JSON::Parse does not accept non-characters or parts of surrogate pairs
-as UTF-8 bytes. See also the discussion under L</JSON Parsing Test
-Suite>.
+The latest specification for JSON, L</RFC 8259>, specifies it to be a
+UTF-8 only format.
+
+JSON::Parse does not accept Unicode non-characters (U+FFFF, UFDDO,
+etc.), UTF-8 representing surrogate pair code points, or bytes outside
+the range of Unicode code points as UTF-8 bytes.
=back
@@ -1198,7 +1229,7 @@ L</detect_collisions>. For example an input like
gives output
- JSON error at line 1, byte 23/31: Name is not unique: "hocus" parsing object starting from byte 1 at blib/lib/JSON/Parse.pm line 109.
+ JSON error at line 1, byte 23/31: Name is not unique: "hocus" parsing object starting from byte 1 at blib/lib/JSON/Parse.pm line 113.
@@ -1220,7 +1251,7 @@ This happens if you set JSON false to map to a true value:
To switch off this warning, use L</no_warn_literals>.
-This warning was added in version 0.38.
+🎲 This warning was added in version 0.38.
=item User-defined value for JSON true evaluates as false
@@ -1230,7 +1261,7 @@ This happens if you set JSON true to map to a false value:
To switch off this warning, use L</no_warn_literals>.
-This warning was added in version 0.38.
+🎲 This warning was added in version 0.38.
=item User-defined value overrules copy_literals
@@ -1238,7 +1269,7 @@ This warning is given if you set up literals with L</copy_literals>
then you also set up your own true, false, or null values with
L</set_true>, L</set_false>, or L</set_null>.
-This warning was added in version 0.38.
+🎲 This warning was added in version 0.38.
=back
@@ -1267,15 +1298,14 @@ able to fully work out the reason behind the better speed.
There is some benchmarking code in the github repository under the
directory "benchmarks" for those wishing to test these claims. The
-script L<F<benchmarks/bench>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/benchmarks/bench> is an adaptation of the similar
-script in the L<JSON::XS> distribution. The script L<F<benchmarks/pub-bench.pl>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/benchmarks/pub-bench.pl> runs the benchmarks and prints them
+script L<F<benchmarks/bench>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/benchmarks/bench> is an adaptation of the similar
+script in the L<JSON::XS> distribution. The script L<F<benchmarks/pub-bench.pl>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/benchmarks/pub-bench.pl> runs the benchmarks and prints them
out as POD.
-The following benchmark tests used version 0.47 of JSON::Parse and
-version 3.03 of JSON::XS on Perl Version 18.2, compiled with Clang
-version 3.4.1 on FreeBSD 10.3. The files in the "benchmarks" directory
-of JSON::Parse. "short.json" and "long.json" are the benchmarks used
-by JSON::XS.
+The following benchmark tests used version 0.58_01 of JSON::Parse, version 4.03 of L</JSON::XS>, and version 4.25 of L</Cpanel::JSON::XS> on Perl
+version v5.32.0 compiled with Clang version FreeBSD clang version 10.0.1 on FreeBSD 12.2. The files in the "benchmarks" directory
+of JSON::Parse. F<short.json> and F<long.json> are the benchmarks used
+by L</JSON::XS>.
=over
@@ -1285,9 +1315,10 @@ by JSON::XS.
--------------+------------+------------+
module | 1/min | min |
--------------|------------|------------|
- JP::valid | 776722.963 | 0.0000129 |
- JSON::Parse | 285326.803 | 0.0000350 |
- JSON::XS | 257319.264 | 0.0000389 |
+ Cpanel | 313007.761 | 0.0000319 |
+ JP::valid | 838860.800 | 0.0000119 |
+ JSON::Parse | 310689.185 | 0.0000322 |
+ JSON::XS | 303935.072 | 0.0000329 |
--------------+------------+------------+
@@ -1297,9 +1328,10 @@ by JSON::XS.
--------------+------------+------------+
module | 1/min | min |
--------------|------------|------------|
- JP::valid | 13985.675 | 0.0007150 |
- JSON::Parse | 5128.138 | 0.0019500 |
- JSON::XS | 5919.977 | 0.0016892 |
+ Cpanel | 5611.860 | 0.0017819 |
+ JP::valid | 13586.991 | 0.0007360 |
+ JSON::Parse | 4924.048 | 0.0020308 |
+ JSON::XS | 6406.452 | 0.0015609 |
--------------+------------+------------+
@@ -1309,9 +1341,10 @@ by JSON::XS.
--------------+------------+------------+
module | 1/min | min |
--------------|------------|------------|
- JP::valid | 285326.803 | 0.0000350 |
- JSON::Parse | 32589.775 | 0.0003068 |
- JSON::XS | 32263.877 | 0.0003099 |
+ Cpanel | 34749.826 | 0.0002878 |
+ JP::valid | 270600.258 | 0.0000370 |
+ JSON::Parse | 34017.064 | 0.0002940 |
+ JSON::XS | 35726.610 | 0.0002799 |
--------------+------------+------------+
@@ -1321,9 +1354,10 @@ by JSON::XS.
--------------+------------+------------+
module | 1/min | min |
--------------|------------|------------|
- JP::valid | 128266.177 | 0.0000780 |
- JSON::Parse | 52626.148 | 0.0001900 |
- JSON::XS | 19849.995 | 0.0005038 |
+ Cpanel | 46759.242 | 0.0002139 |
+ JP::valid | 117817.528 | 0.0000849 |
+ JSON::Parse | 46759.242 | 0.0002139 |
+ JSON::XS | 19195.899 | 0.0005209 |
--------------+------------+------------+
@@ -1333,9 +1367,10 @@ by JSON::XS.
--------------+------------+------------+
module | 1/min | min |
--------------|------------|------------|
- JP::valid | 313007.761 | 0.0000319 |
- JSON::Parse | 47180.022 | 0.0002120 |
- JSON::XS | 28826.832 | 0.0003469 |
+ Cpanel | 33026.016 | 0.0003028 |
+ JP::valid | 384798.532 | 0.0000260 |
+ JSON::Parse | 40840.351 | 0.0002449 |
+ JSON::XS | 33689.189 | 0.0002968 |
--------------+------------+------------+
@@ -1345,9 +1380,10 @@ by JSON::XS.
--------------+------------+------------+
module | 1/min | min |
--------------|------------|------------|
- JP::valid | 1398.241 | 0.0071518 |
- JSON::Parse | 211.734 | 0.0472291 |
- JSON::XS | 215.100 | 0.0464900 |
+ Cpanel | 212.377 | 0.0470860 |
+ JP::valid | 1309.043 | 0.0076392 |
+ JSON::Parse | 207.491 | 0.0481949 |
+ JSON::XS | 226.439 | 0.0441620 |
--------------+------------+------------+
@@ -1372,10 +1408,14 @@ Crockford.
=head2 Other CPAN modules for parsing and producing JSON
-Modules which we recommend are marked with 👍. Deprecated modules and
-modules which are definitely buggy (bug reports/pull requests ignored)
-and abandoned (no releases for several years) are marked with 👎
-and/or 🐛. Modules we can't work out are marked with 😕.
+
+
+The ⭐ represents the number of votes this module has received
+on metacpan, on a logarithmic scale. Modules which we recommend are
+marked with 👍. Deprecated modules and modules which are definitely
+buggy (bug reports/pull requests ignored) and abandoned (no releases
+for several years) are marked with 👎 and/or 🐛. Modules we can't work
+out are marked with 😕.
=over
@@ -1403,58 +1443,107 @@ parsers.
=back
+
=item Reading and writing JSON
=over
+
=item L<Cpanel::JSON::XS>
-This is a fork of L<JSON::XS> related to a disagreement about how to
-report bugs. Please see the module for details.
+
+[⭐⭐ Author: L<RURBAN|https://metacpan.org/author/RURBAN>; Date: C<2020-10-28>; Version: C<4.25>]
+
+
+
+This is a fork of L<JSON::XS>. Please see the module for details about
+the reasons for the fork.
+
=item L<File::JSON::Slurper>
+
+[⭐ Author: L<NEILB|https://metacpan.org/author/NEILB>; Date: C<2020-11-18>; Version: C<1.00>]
+
+
+
Slurp a JSON file into a data structure, and the reverse. It relies on
L</JSON::MaybeXS>.
+
=item L<Glib::JSON>
-Uses the JSON library from Glib, a library of C functions for the
-Linux GNOME desktop project.
-=item L<Inline::JSON>
+[⭐ Author: L<EBASSI|https://metacpan.org/author/EBASSI>; Date: C<2015-04-19>; Version: C<0.002>]
+
+
+
+Uses the JSON library from Glib, a library of C functions for the
+Linux GNOME desktop project, so it is independent of the other CPAN
+modules. Judging from the fairly sparse documentation, it seems to be
+a module where you build the JSON on the fly rather than converting a
+Perl structure wholesale into JSON.
-Include a chunk of JSON text right into your Perl program. Relies on
-L</JSON>.
=item L<JSON>
+
+[⭐⭐ Author: L<ISHIGAKI|https://metacpan.org/author/ISHIGAKI>; Date: C<2019-02-23>; Version: C<4.02>]
+
+
+
This calls on either L<JSON::PP> or L<JSON::XS>.
+
=item L<JSON::DWIW>
+
+[Author: L<DOWENS|https://metacpan.org/author/DOWENS>; Date: C<2010-09-29>; Version: C<0.47>]
+
+
+
👎🐛 This module "Does What I Want", where "I" refers to the module's
author. Development seems to have ceased in 2010, there is a long list
of unfixed bugs, and some of the module's features seem to predate
-Unicode support in Perl.
+Unicode support in Perl. It is written in XS, and it claims to accept
+a wide variety of non-JSON formats such as comments, single-quoted
+strings, trailing commas, etc.
+
=item L<JSON::PP>
+
+[⭐⭐ Author: L<ISHIGAKI|https://metacpan.org/author/ISHIGAKI>; Date: C<2020-07-08>; Version: C<4.05>]
+
+
+
This is part of the Perl core, installed when you install Perl. "PP"
stands for "Pure Perl", which means it is in Perl-only without the XS
(C-based) parsing. This is slower but may be necessary if you cannot
install modules requiring a C compiler.
+
=item L<JSON::Slurper>
+
+[⭐ Author: L<SRCHULO|https://metacpan.org/author/SRCHULO>; Date: C<2019-10-30>; Version: C<0.12>]
+
+
+
Convenient file slurping and spurting of data using JSON. Uses
L</JSON::PP> or L</Cpanel::JSON::XS> if available. The basic idea
seems to be that it uses context to return arrays or hashes as
required, and read and write files without extra stages of opening and
closing the file.
+
=item L<JSON::Syck>
+
+[⭐⭐ Author: L<TODDR|https://metacpan.org/author/TODDR>; Date: C<2020-10-26>; Version: C<1.34>]
+
+
+
👎🐛 Takes advantage of a similarity between YAML (yet another markup
language) and JSON to provide a JSON parser/producer using
L<YAML::Syck>.
@@ -1466,124 +1555,176 @@ about things like failing to process equals signs. However, the
maintainer is fixing some of the bugs and making new releases, so
we're not really sure.
+
=item L<JSON::Tiny>
-This is a fork of L</Mojo::JSON>.
-=item L<JSON::Util>
+[⭐⭐ Author: L<DAVIDO|https://metacpan.org/author/DAVIDO>; Date: C<2017-11-12>; Version: C<0.58>]
+
+
+
+This is a fork of L</Mojo::JSON>.
-Relies on L<JSON::MaybeXS>.
=item L<JSON::XS>
+
+[⭐⭐⭐ Author: L<MLEHMANN|https://metacpan.org/author/MLEHMANN>; Date: C<2020-10-27>; Version: C<4.03>]
+
+
+
This is an all-purpose JSON module in XS, which means it requires a C
compiler to install.
+
=item L<JSON::YAJL>
-👎🐛 Wraps a C library called yajl. The module has been abandoned since
-ten years ago, bug reports include serious errors, and pull requests
-have been ignored.
+
+[⭐ Author: L<LBROCARD|https://metacpan.org/author/LBROCARD>; Date: C<2011-08-05>; Version: C<0.10>]
+
+
+
+👎🐛 Wraps a C library called yajl. The module has been abandoned
+since ten years ago. Bug reports include serious errors, and pull
+requests have been ignored.
+
=item L<Mojo::JSON>
-Part of the L<Mojolicious> standalone web framework, "pure Perl" JSON
-reader/writer. As of version 6.25 of Mojolicious, this actually
-depends on L</JSON::PP>.
-=item L<Pegex::JSON>
+[⭐⭐⭐ Author: L<SRI|https://metacpan.org/author/SRI>; Date: C<2020-12-30>; Version: C<8.70>]
+
-🐛 Based on L<Pegex>. See
-L<our bug report|https://github.com/pegex-parser/pegex-json-pm/issues/3>.
+
+Part of the L<Mojolicious> standalone web framework, "pure Perl" JSON
+reader/writer. As of version 8.70 of Mojolicious, this actually
+depends on L</JSON::PP> but will load L</Cpanel::JSON::XS> if it is
+available.
=back
-=item Special-purpose modules
+=item Combination modules
+
+These modules rely on more than one back-end module to process JSON
+for you.
=over
-=item L<App::JSON::to>
-Convert JSON data to other formats. It reads your JSON file or input
-and converts it into either YAML or Perl native format using
-L<Data::Dumper>.
+=item L<JSON::Any>
-=item L<boolean>
-👍 This module offers C<true> and C<false> literals similar to JSON.
+[⭐ Author: L<ETHER|https://metacpan.org/author/ETHER>; Date: C<2015-06-10>; Version: C<1.39>]
-=item L<Config::JSON>
-Configuration files in JSON
-=item L<Devel::JSON>
+👎 This now-deprecated module combines L</JSON::DWIW>, L</JSON::XS>
+versions one and two, and L</JSON::Syck>.
-For one-liners.
-=over
+=item L<JSON::MaybeXS>
-If you use this module from the command-line, the last value of your
-one-liner (-e) code will be serialized as JSON data.
-=back
+[⭐⭐ Author: L<ETHER|https://metacpan.org/author/ETHER>; Date: C<2020-11-13>; Version: C<1.004003>]
-=item L<JSON::Builder>
-Create JSON under memory limitations.
-=item L<JSON::Color>
+A module which combines L</Cpanel::JSON::XS>, L</JSON::XS>, and
+L</JSON::PP>. The original L</JSON> combines L</JSON::XS> and
+L</JSON::PP>, but this prioritizes L</Cpanel::JSON::XS> over
+L</JSON::XS>.
-🌈 This module generates JSON colorized with ANSI escape sequences.
-=item L<JSON::MultiValueOrdered> and L<JSON::Tiny::Subclassable>
+=item L<JSON::XS::VersionOneAndTwo>
-C<JSON::MultiValueOrdered> is a special-purpose module for parsing
-JSON objects which have key collisions (something like
-C<{"a":1,"a":2}>) within objects.
-(JSON::Parse's handling of key collisions is discussed in L</Key
-collisions> in this document.)
+[Author: L<LBROCARD|https://metacpan.org/author/LBROCARD>; Date: C<2008-02-13>; Version: C<0.31>]
-=item L<JSON::Path>
-Search nested hashref/arrayref structures using JSONPath.
-=item L<JSON::Pointer>
+👎 A "combination module" which supports two different interfaces of
+L</JSON::XS>. However, JSON::XS is now onto version 4.
-Extract parts of a JSON string.
-=item L<JSON::String>
+=item L<Mojo::JSON::MaybeXS>
-Automatically change a JSON string when a data structure changes using
-tied scalars.
+
+[⭐ Author: L<DBOOK|https://metacpan.org/author/DBOOK>; Date: C<2019-08-07>; Version: C<1.002>]
+
+
+
+👎 This pulls in L</JSON::MaybeXS> instead of L</Mojo::JSON> for
+L<Mojolicious> users. It seems to have been rendered obsolete by
+modern versions of Mojolicious due to changes to make that depend on
+L</Cpanel::JSON::XS> if available.
=back
+
=item Test-related modules
=over
+
+=item L<Test2::Tools::JSON>
+
+
+[Author: L<AKIYM|https://metacpan.org/author/AKIYM>; Date: C<2019-08-07>; Version: C<0.05>]
+
+
+
+
=item L<Test::Deep::JSON>
+
+[⭐ Author: L<MOTEMEN|https://metacpan.org/author/MOTEMEN>; Date: C<2018-04-24>; Version: C<0.05>]
+
+
+
Compare JSON with L<Test::Deep>. As of version 0.05, it relies on
L</JSON::MaybeXS>.
+
=item L<Test::JSON>
+
+[⭐ Author: L<OVID|https://metacpan.org/author/OVID>; Date: C<2009-08-09>; Version: C<0.11>]
+
+
+
👎 This offers a way to compare two different JSON strings to see if
they refer to the same object. The most recent version, 0.11, was
released in 2009, and it relies on the deprecated L</JSON::Any>, which
makes it essentially abandoned.
+
=item L<Test::JSON::Entails>
+
+[Author: L<VOJ|https://metacpan.org/author/VOJ>; Date: C<2012-09-14>; Version: C<0.2>]
+
+
+
👎 Test whether one JSON or Perl structure entails/subsumes
another. The most recent version is from 2012, and it relies on
-L</JSON::Any>, so it is probably abandoned.
+L</JSON::Any>, so it is probably abandoned. Also, oddly but not
+uniquely for CPAN modules with the name JSON in the title, it seems to
+not actually have that much to do with JSON, which is a data
+serialisation format, but actually be testing Perl hashes and arrays.
+
=item L<Test::JSON::More>
-JSON Test Utility. As of version 0.02, it relies on L</JSON>.
+
+[Author: L<BAYASHI|https://metacpan.org/author/BAYASHI>; Date: C<2016-04-28>; Version: C<0.02>]
+
+
+
+JSON Test Utility. As of version 0.02, it relies on L</JSON> but it is
+able to use L</JSON::XS> instead, and so probably L</Cpanel::JSON::XS>
+would be OK too. According to the documentation, it can test JSON for
+validity and compare JSON strings with keys in a different order, and
+presumably with different whitespace.
=back
@@ -1593,17 +1734,35 @@ These untangle numbers, strings, and booleans into JSON types.
=over
+
=item L<JSON::TypeInference>
+
+[Author: L<AEREAL|https://metacpan.org/author/AEREAL>; Date: C<2015-10-26>; Version: C<v1.0.2>]
+
+
+
😕 Virtually undocumented, it's not clear what this does.
+
=item L<JSON::Types>
+
+[⭐ Author: L<TYPESTER|https://metacpan.org/author/TYPESTER>; Date: C<2012-10-17>; Version: C<0.05>]
+
+
+
Change the type of a Perl variable so that it comes out as a number, a
string, or a boolean in the output JSON.
+
=item L<JSON::Types::Flexible>
+
+[Author: L<PINE|https://metacpan.org/author/PINE>; Date: C<2017-04-01>; Version: C<0.03>]
+
+
+
The module is barely documented, but from looking at L<the test
file|https://metacpan.org/source/PINE/JSON-Types-Flexible-0.03/t%2Fjson%2Ftypes%2Fflexible%2Fclass.t>,
this seems to enable you to change the output type of a number or a
@@ -1611,8 +1770,14 @@ string so that you can, for example, make the number C<1> come out as
either a number, C<1>, a string C<"1">, or a boolean, C<true>, in the
output JSON.
+
=item L<JSON::Typist>
+
+[⭐ Author: L<RJBS|https://metacpan.org/author/RJBS>; Date: C<2019-12-26>; Version: C<0.006>]
+
+
+
"Replace mushy strings and numbers with rigidly typed replacements"
Since Perl muddles strings and numbers, this enables you to work out
@@ -1620,34 +1785,203 @@ whether your input JSON was C<"123"> (a string) or C<123> (a number).
=back
-=item Combination modules
+=item Special-purpose modules
+
+=over
+
+
+=item L<App::JSON::to>
+
+
+[⭐ Author: L<DOLMEN|https://metacpan.org/author/DOLMEN>; Date: C<2015-03-04>; Version: C<1.000>]
-These modules rely on more than one back-end module to process JSON
-for you.
+
+
+Convert JSON data to other formats. It reads your JSON file or input
+and converts it into either YAML or Perl native format using
+L<Data::Dumper>.
+
+
+=item L<boolean>
+
+
+[⭐⭐ Author: L<INGY|https://metacpan.org/author/INGY>; Date: C<2016-07-08>; Version: C<0.46>]
+
+
+
+👍 This module offers C<true> and C<false> literals in Perl, so you just have
+
+ use boolean;
+ my $something = true;
+
+This is very useful for dealing with JSON.
+
+
+=item L<Config::JSON>
+
+
+[Author: L<RIZEN|https://metacpan.org/author/RIZEN>; Date: C<2014-12-25>; Version: C<1.5202>]
+
+
+
+Configuration files in JSON, with hash comments also allowed.
+
+
+=item L<Devel::JSON>
+
+
+[⭐ Author: L<DOLMEN|https://metacpan.org/author/DOLMEN>; Date: C<2017-09-03>; Version: C<1.001>]
+
+
+
+For one-liners.
=over
-=item L<JSON::Any>
+If you use this module from the command-line, the last value of your
+one-liner (-e) code will be serialized as JSON data.
-👎 This now-deprecated module combines L</JSON::DWIW>, L</JSON::XS>
-versions one and two, and L</JSON::Syck>.
+=back
-=item L<JSON::MaybeXS>
-A module which combines L</Cpanel::JSON::XS>, L</JSON::XS>, and
-L</JSON::PP>. The original L</JSON> combines L</JSON::XS> and
-L</JSON::PP>, but this prioritizes L</Cpanel::JSON::XS> over
-L</JSON::XS>.
+=item L<Inline::JSON>
-=item L<JSON::XS::VersionOneAndTwo>
-👎 A "combination module" which supports two different interfaces of
-L</JSON::XS>. However, JSON::XS is now onto version 4.
+[Author: L<KILNA|https://metacpan.org/author/KILNA>; Date: C<2012-07-27>; Version: C<v1.0.4>]
+
+
+
+"Embed JSON data structures directly into your Perl code". Relies on
+L</JSON>.
+
+
+=item L<JSON::Builder>
+
+
+[Author: L<KNI|https://metacpan.org/author/KNI>; Date: C<2015-04-16>; Version: C<0.04>]
+
+
+
+Create JSON under memory limitations.
+
+
+=item L<JSON::Color>
+
+
+[⭐ Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>; Date: C<2020-06-09>; Version: C<0.130>]
+
+
+
+🌈 This module generates JSON colorized with ANSI escape sequences.
+
+
+=item L<JSON_File>
+
+
+[⭐ Author: L<GETTY|https://metacpan.org/author/GETTY>; Date: C<2014-09-11>; Version: C<0.004>]
+
+
+
+
+=item L<JSON::MultiValueOrdered>
+
+
+[Author: L<TOBYINK|https://metacpan.org/author/TOBYINK>; Date: C<2020-01-27>; Version: C<0.006>]
+
+
+
+C<JSON::MultiValueOrdered> is a special-purpose module for parsing
+JSON objects which have key collisions (something like
+C<{"a":1,"a":2}>) within objects.
+
+(JSON::Parse's handling of key collisions is discussed in L</Key
+collisions> in this document.)
+
+
+=item L<JSON::String>
+
+
+[Author: L<BRUMMETT|https://metacpan.org/author/BRUMMETT>; Date: C<2015-02-04>; Version: C<v0.2.0>]
+
+
+
+Automatically change a JSON string when a data structure changes using
+tied scalars.
+
+=back
+
+=item Patch, path, pointer, and transform modules
+
+=over
+
+
+=item L<JSON::Assert>
+
+
+[Author: L<SGREEN|https://metacpan.org/author/SGREEN>; Date: C<2017-07-07>; Version: C<0.08>]
+
+
+
+"Asserts JSONPaths into a JSON data structure for correct
+values/matches"
+
+
+=item L<JSON::MergePatch>
+
+
+[⭐ Author: L<SOJIRO|https://metacpan.org/author/SOJIRO>; Date: C<2016-02-24>; Version: C<0.04>]
+
+
+
+
+=item L<JSON::Patch>
+
+
+[Author: L<MIXAS|https://metacpan.org/author/MIXAS>; Date: C<2018-10-25>; Version: C<0.04>]
+
+
+
+😕 We don't know what this does, or how it relates to JSON. The example
+in the synopsis section of the document doesn't show any JSON, it
+shows an example of altering nested hashes in Perl.
+
+
+=item L<JSON::Path>
+
+
+[⭐ Author: L<POPEFELIX|https://metacpan.org/author/POPEFELIX>; Date: C<2018-05-05>; Version: C<0.420>]
+
+
+
+Search nested hashref/arrayref structures using JSONPath.
+
+
+=item L<JSON::Pointer>
+
+
+[⭐ Author: L<ZIGOROU|https://metacpan.org/author/ZIGOROU>; Date: C<2015-08-13>; Version: C<0.07>]
+
+
+
+Extract parts of a JSON string.
+
+
+=item L<JSON::T>
+
+
+[⭐ Author: L<TOBYINK|https://metacpan.org/author/TOBYINK>; Date: C<2014-09-28>; Version: C<0.104>]
+
+
+
+Transform JSON using JsonT
+
+
+=item L<JSON::Transform>
+
+
+[⭐ Author: L<ETJ|https://metacpan.org/author/ETJ>; Date: C<2020-01-01>; Version: C<0.03>]
-=item L<Mojo::JSON::MaybeXS>
-This pulls in L</JSON::MaybeXS> instead of L</Mojo::JSON> for
-L<Mojolicious> users.
=back
@@ -1657,16 +1991,34 @@ These modules extend JSON with comments and other things.
=over
+
=item L<JSON::Diffable>
+
+[⭐ Author: L<PHAYLON|https://metacpan.org/author/PHAYLON>; Date: C<2014-12-10>; Version: C<0.000002>]
+
+
+
"A relaxed and easy diffable JSON variant"
+
=item L<JSON::Relaxed>
+
+[Author: L<MIKO|https://metacpan.org/author/MIKO>; Date: C<2016-04-30>; Version: C<0.05>]
+
+
+
"An extension of JSON that allows for better human-readability".
+
=item L<JSONY>
+
+[⭐ Author: L<INGY|https://metacpan.org/author/INGY>; Date: C<2020-04-27>; Version: C<v0.1.21>]
+
+
+
"Relaxed JSON with a little bit of YAML"
=back
@@ -1675,13 +2027,33 @@ These modules extend JSON with comments and other things.
=over
+
=item L<JSON::API>
+
+[⭐ Author: L<GFRANKS|https://metacpan.org/author/GFRANKS>; Date: C<2019-07-01>; Version: C<v1.1.1>]
+
+
+
Combines L<LWP::UserAgent> and L<JSON> to make a unified module to
communicate with a web server via JSON.
+
+=item L<LWP::JSON::Tiny>
+
+
+[⭐ Author: L<SKINGTON|https://metacpan.org/author/SKINGTON>; Date: C<2018-05-11>; Version: C<0.014>]
+
+
+
+
=item L<WWW::JSON>
+
+[⭐ Author: L<ANTIPASTA|https://metacpan.org/author/ANTIPASTA>; Date: C<2015-05-27>; Version: C<1.02>]
+
+
+
"Make working with JSON Web API's as painless as possible"
=back
@@ -1692,16 +2064,80 @@ These modules extend the existing modules with some extra bits.
=over
+
=item L<JSON::XS::Sugar>
+
+[Author: L<MAXMIND|https://metacpan.org/author/MAXMIND>; Date: C<2015-04-01>; Version: C<1.01>]
+
+
+
Provides booleans and number/string forcing for L</JSON::XS>.
+
=item L<Silki::JSON>
+
+[⭐ Author: L<DROLSKY|https://metacpan.org/author/DROLSKY>; Date: C<2011-09-19>; Version: C<0.29>]
+
+
+
Switches on formatting and strict utf8 in a L</JSON::XS> object.
=back
+=item Demonstration modules
+
+These modules provide a JSON parser as a demonstration of another
+technology.
+
+=over
+
+
+=item L<JSON::Decode::Marpa>
+
+
+[Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>; Date: C<2014-08-27>; Version: C<0.02>]
+
+
+
+
+=item L<JSON::Decode::Regexp>
+
+
+[Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>; Date: C<2018-03-25>; Version: C<0.101>]
+
+
+
+🐛🦟🦋🐞 JSON parser as a single Perl Regex, originally by Randal
+Schwartz. This may be ingenious, but it's not remotely a useful JSON
+parser. For example, looking at the string part, it provides no
+Unicode validation, L<no support for Unicode
+escapes|https://metacpan.org/release/JSON-Decode-Regexp/source/lib/JSON/Decode/Regexp.pm#L141>
+and it L<allows invalid escapes such as
+C<\xFF>|https://metacpan.org/release/JSON-Decode-Regexp/source/lib/JSON/Decode/Regexp.pm#L137>.
+
+
+=item L<MarpaX::Demo::JSONParser>
+
+
+[Author: L<RSAVAGE|https://metacpan.org/author/RSAVAGE>; Date: C<2019-06-18>; Version: C<1.08>]
+
+
+
+
+=item L<Pegex::JSON>
+
+
+[Author: L<INGY|https://metacpan.org/author/INGY>; Date: C<2020-01-22>; Version: C<0.31>]
+
+
+
+🐛 Based on L<Pegex>. See
+L<our bug report|https://github.com/pegex-parser/pegex-json-pm/issues/3>.
+
+=back
+
=item Other modules
Modules which are parts of bigger releases have not been included here
@@ -1709,12 +2145,24 @@ except by accident.
=over
+
=item L<App::JSON::Tools>
+
+[Author: L<KABLAMO|https://metacpan.org/author/KABLAMO>; Date: C<2016-08-05>; Version: C<0.01>]
+
+
+
Undocumented command-line tools for JSON.
+
=item L<App::JSONPretty>
+
+[⭐ Author: L<MSTROUT|https://metacpan.org/author/MSTROUT>; Date: C<2011-02-02>; Version: C<1>]
+
+
+
👎🐛 JSON prettification script. For whatever reason the script
encapsulates the entirety of an old version of the L</JSON> module
dating from before L</JSON::PP> was included in the Perl core.
@@ -1723,44 +2171,84 @@ If you need this kind of script, there is something called L<json_xs>
which comes with L</JSON::XS>, or equivalently L<cpanel_json_xs> in
the forked module L</Cpanel::JSON::XS>.
+
=item L<ARGV::JSON>
+
+[⭐ Author: L<MOTEMEN|https://metacpan.org/author/MOTEMEN>; Date: C<2013-12-18>; Version: C<0.01>]
+
+
+
+
=item L<Haineko::JSON>
-😕 It says "Wrapper class to load/dump JSON" but we're not sure what
-the author means, for example what does it mean to say "loading JSON
-from scalar value"? Every module which deals with JSON deals with
-parsing JSON from a scalar, so why is a wrapper class necessary?
+
+[⭐ Author: L<AKXLIX|https://metacpan.org/author/AKXLIX>; Date: C<2014-01-25>; Version: C<v0.2.16>]
+
+
+
+😕 We can't quite figure out the documentation here.
+
=item L<JS::JSON>
+
+[Author: L<INGY|https://metacpan.org/author/INGY>; Date: C<2008-08-30>; Version: C<0.02>]
+
+
+
👎 This is JavaScript code which was uploaded to CPAN. The original
JavaScript is now obsolete since the thing it codes is included in all
modern web browsers.
-=item L<JSON::Assert>
-
-"Asserts JSONPaths into a JSON data structure for correct
-values/matches"
=item L<JSON::Eval>
+
+[Author: L<TOBYINK|https://metacpan.org/author/TOBYINK>; Date: C<2019-10-27>; Version: C<0.002>]
+
+
+
Eval Perl code found in JSON. This module enables one to encode and
decode Perl scalar references and code references to JSON.
+
=item L<JSON::ize>
+
+[⭐ Author: L<MAJENSEN|https://metacpan.org/author/MAJENSEN>; Date: C<2019-07-13>; Version: C<0.202>]
+
+
+
Something about one-liners.
+
=item L<JSON::JSend>
+
+[Author: L<HOEKIT|https://metacpan.org/author/HOEKIT>; Date: C<2016-04-23>; Version: C<0.02>]
+
+
+
+
=item L<JSON::Lines>
+
+[⭐ Author: L<LNATION|https://metacpan.org/author/LNATION>; Date: C<2020-10-25>; Version: C<0.03>]
+
+
+
"JSON Lines is a convenient format for storing structured data that
may be processed one record at a time."
+
=item L<JSON::Meth>
+
+[⭐ Author: L<ZOFFIX|https://metacpan.org/author/ZOFFIX>; Date: C<2015-11-28>; Version: C<1.001007>]
+
+
+
😕 Claims to be "no nonsense JSON encoding/decoding as method calls on
data". From the documentation:
@@ -1772,28 +2260,65 @@ or decode a JSON string to a Perl data structure.
=back
+
=item L<JSON::ON>
-JavaScript object notation object notator.
-=item L<JSON::Patch>
+[Author: L<EWILHELM|https://metacpan.org/author/EWILHELM>; Date: C<2013-06-26>; Version: C<v0.0.3>]
+
+
+
+JavaScript object notation object notator.
-😕 We don't know what this does, or how it relates to JSON. The example
-in the synopsis section of the document doesn't show any JSON, it
-shows an example of altering nested hashes in Perl.
=item L<JSON::SL>
+
+[⭐ Author: L<MNUNBERG|https://metacpan.org/author/MNUNBERG>; Date: C<2017-11-10>; Version: C<v1.0.7>]
+
+
+
😕
-=item L<JSON::Streaming::Reader> and L<JSON::Streaming::Writer>
-=item L<JSON::T>
+=item L<JSON::Streaming::Reader>
+
+
+[⭐ Author: L<MART|https://metacpan.org/author/MART>; Date: C<2012-11-24>; Version: C<0.06>]
+
+
+
+
+=item L<JSON::Streaming::Writer>
+
+
+[Author: L<MART|https://metacpan.org/author/MART>; Date: C<2012-11-24>; Version: C<0.03>]
+
+
+
+
+=item L<JSON::Util>
+
+
+[Author: L<JKUTEJ|https://metacpan.org/author/JKUTEJ>; Date: C<2015-09-03>; Version: C<0.06>]
+
+
+
+Relies on L<JSON::MaybeXS> and the author's other module L<IO::Any>,
+so that you can put either a file name or a JSON string as the
+argument and it tries to work out which one you have given it. That is
+ingenious, but it seems that if you are a programmer who cannot
+distinguish whether your input string is a file name or JSON, you have
+a very serious problem.
-Transform JSON using JsonT
=item L<JSON::XS::ByteString>
+
+[⭐ Author: L<CINDY|https://metacpan.org/author/CINDY>; Date: C<2020-04-18>; Version: C<1.004>]
+
+
+
😕 L<The
README|https://metacpan.org/source/CINDY/JSON-XS-ByteString-1.004/README>
claims it is a "thin wrapper around JSON::XS", but L<it contains a
@@ -1809,8 +2334,14 @@ We haven't tried downloading this or installing it, but according to
the documentation, this module encodes numbers with quotes around
them, so C<< {this => 2} >> turns into C<{"this":"2"}>.
+
=item L<Text::JSON::Nibble>
+
+[Author: L<DAEMON|https://metacpan.org/author/DAEMON>; Date: C<2017-05-02>; Version: C<1.01>]
+
+
+
Nibble complete JSON objects from buffers.
This seems to be for extracting JSON from the midst of noise.
@@ -1842,13 +2373,6 @@ If you need confirmation, use its --verbose option:
linedecomps.json is valid JSON.
radkfile-radicals.json is valid JSON.
-=head1 TEST RESULTS
-
-The CPAN testers results are at the usual place.
-
-The ActiveState test results are at
-L<http://code.activestate.com/ppm/JSON-Parse/>.
-
=head1 DEPENDENCIES
=over
@@ -1860,9 +2384,10 @@ L<http://code.activestate.com/ppm/JSON-Parse/>.
=head1 EXPORTS
The module exports nothing by default. Functions L</parse_json>,
-L</parse_json_safe>, L</json_file_to_perl>, L</valid_json> and
+L</parse_json_safe>, L</read_json>, L</valid_json> and
L</assert_valid_json>, as well as the old function names
-L</validate_json> and L</json_to_perl>, can be exported on request.
+L</validate_json>, L</json_file_to_perl>, and L</json_to_perl>, can be
+exported on request.
All of the functions can be exported using the tag ':all':
@@ -1878,7 +2403,7 @@ supplied with the module in the F</t/> subdirectory of the
distribution.
More extensive testing code is in the git repository. This is not
-supplied in the CPAN distribution. A script, L<F<randomjson.pl>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/randomjson.pl>,
+supplied in the CPAN distribution. A script, L<F<randomjson.pl>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/randomjson.pl>,
generates a set number of bytes of random JSON and checks that the
module's bytewise validation of input is correct. It does this by
taking a valid fragment, then adding each possible byte from 0 to 255
@@ -1888,17 +2413,17 @@ it to the fragment and continuing the process until a complete valid
JSON input is formed. The module has undergone about a billion
repetitions of this test.
-This setup relies on a C file, L<F<json-random-test.c>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/json-random-test.c>, which
-isn't in the CPAN distribution, and it also requires L<F<Json3.xs>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/Json3.xs> to be edited to make the macro C<TESTRANDOM> true
+This setup relies on a C file, L<F<json-random-test.c>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/json-random-test.c>, which
+isn't in the CPAN distribution, and it also requires L<F<Json3.xs>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/Json3.xs> to be edited to make the macro C<TESTRANDOM> true
(uncomment line 7 of the file). The testing code uses C
setjmp/longjmp, so it's not guaranteed to work on all operating
systems and is commented out for CPAN releases.
-A pure C version called L<F<random-test.c>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/random-test.c> also exists. This applies
+A pure C version called L<F<random-test.c>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/random-test.c> also exists. This applies
exactly the same tests, and requires no Perl at all.
If you're interested in testing your own JSON parser, the outputs
-generated by L<F<randomjson.pl>|https://github.com/benkasminbullock/JSON-Parse/blob/6df355c947edf0bf190c0f3631ea46e65d4bb7ed/randomjson.pl> are quite a good place to
+generated by L<F<randomjson.pl>|https://github.com/benkasminbullock/JSON-Parse/e10440285845d6b0f29746bce84c6b546e557f6f/randomjson.pl> are quite a good place to
start. The default is to produce UTF-8 output, which looks pretty
horrible since it tends to produce long strings of UTF-8
garbage. (This is because it chooses randomly from 256 bytes and the
@@ -1921,23 +2446,35 @@ valid UTF-8 as input. See L</UTF-8 only>.
In our opinion it would be a disservice to users of this module to
allow bytes containing useless fragments such as incomplete parts of
surrogate pairs, or invalid characters, just because the JSON
-specification doesn't actually explicitly rule out rejecting these
-kinds of garbage inputs. Please see the function C<daft_test> in the
-file F<xt/JPXT.pm> for exactly which of these elements of the test
-suite we do not comply with. See also Douglas Crockford, the inventor
-of JSON's, L<JSON
+specification doesn't actually explicitly demand rejecting these kinds
+of garbage inputs. Please see the function C<daft_test> in the file
+F<xt/JPXT.pm> for exactly which of these elements of the test suite we
+do not comply with. We note that this comment from Douglas Crockford,
+the inventor of JSON, L<JSON
parser|https://github.com/douglascrockford/JSON-c/blob/master/utf8_decode.c#L38-L43>,
-dated 2005.
+dated 2005, agrees with our opinion on this point.
JSON::Parse version 0.58 also introduced L</get_max_depth> and
L</set_max_depth> to prevent the stack overflow errors caused by some
very deeply nested inputs such as those of the JSON Parsing Test
Suite.
+=head2 Test results
+
+=over
+
+=item L<ActiveState PPM|http://code.activestate.com/ppm/JSON-Parse/>.
+
+=item L<CPAN testers|http://matrix.cpantesters.org/?dist=JSON-Parse+0.59>
+
+=item L<Travis CI|https://travis-ci.com/github/benkasminbullock/JSON-Parse>
+
+=back
+
=head1 ACKNOWLEDGEMENTS
-Toby Inkster (TOBYINK) suggested the new function names which replaced
-the L</OLD INTERFACE> names. Nicolas Immelman and Shlomi Fish
+Toby Inkster (TOBYINK) suggested some of the new function names which
+replaced the L</OLD INTERFACE> names. Nicolas Immelman and Shlomi Fish
(SHLOMIF) reported memory leaks which were fixed in 0.32 and
0.40. Github user kolmogorov42 reported a bug which led to
0.42. Github user SteveGlassman found an error in string copying for
diff --git a/lib/JSON/Tokenize.pm b/lib/JSON/Tokenize.pm
index 1bb386e..859a972 100644
--- a/lib/JSON/Tokenize.pm
+++ b/lib/JSON/Tokenize.pm
@@ -7,7 +7,7 @@ use JSON::Parse;
our @EXPORT_OK = qw/tokenize_json tokenize_start tokenize_next tokenize_start tokenize_end tokenize_type tokenize_child tokenize_text/;
our %EXPORT_TAGS = ('all' => \@EXPORT_OK);
use Carp;
-our $VERSION = '0.58';
+our $VERSION = '0.59';
sub tokenize_text
{
diff --git a/lib/JSON/Tokenize.pod b/lib/JSON/Tokenize.pod
index 6129003..0551fbd 100644
--- a/lib/JSON/Tokenize.pod
+++ b/lib/JSON/Tokenize.pod
@@ -48,8 +48,8 @@ This outputs
=head1 VERSION
-This documents version 0.58 of JSON::Tokenize corresponding to
-L<git commit 6df355c947edf0bf190c0f3631ea46e65d4bb7ed|https://github.com/benkasminbullock/JSON-Parse/commit/6df355c947edf0bf190c0f3631ea46e65d4bb7ed> released on Fri Jan 1 09:59:25 2021 +0900.
+This documents version 0.59 of JSON::Tokenize corresponding to
+L<git commit e10440285845d6b0f29746bce84c6b546e557f6f|https://github.com/benkasminbullock/JSON-Parse/commit/e10440285845d6b0f29746bce84c6b546e557f6f> released on Mon Jan 4 08:46:00 2021 +0900.
diff --git a/see-also-info.json b/see-also-info.json
new file mode 100644
index 0000000..cfdacf9
--- /dev/null
+++ b/see-also-info.json
@@ -0,0 +1,499 @@
+[
+ {
+ "author":"RURBAN",
+ "date":"2020-10-28T07:04:49",
+ "fav":37,
+ "module":"Cpanel::JSON::XS",
+ "version":"4.25"
+ },
+ {
+ "author":"NEILB",
+ "date":"2020-11-18T09:21:24",
+ "fav":3,
+ "module":"File::JSON::Slurper",
+ "version":"1.00"
+ },
+ {
+ "author":"EBASSI",
+ "date":"2015-04-19T19:16:21",
+ "fav":1,
+ "module":"Glib::JSON",
+ "version":"0.002"
+ },
+ {
+ "author":"ISHIGAKI",
+ "date":"2019-02-23T02:26:27",
+ "fav":92,
+ "module":"JSON",
+ "version":"4.02"
+ },
+ {
+ "author":"DOWENS",
+ "date":"2010-09-29T04:57:36",
+ "fav":0,
+ "module":"JSON::DWIW",
+ "version":"0.47"
+ },
+ {
+ "author":"ISHIGAKI",
+ "date":"2020-07-08T19:51:42",
+ "fav":15,
+ "module":"JSON::PP",
+ "version":"4.05"
+ },
+ {
+ "author":"SRCHULO",
+ "date":"2019-10-30T15:44:51",
+ "fav":1,
+ "module":"JSON::Slurper",
+ "version":"0.12"
+ },
+ {
+ "author":"TODDR",
+ "date":"2020-10-26T20:20:42",
+ "fav":17,
+ "module":"JSON::Syck",
+ "version":"1.34"
+ },
+ {
+ "author":"DAVIDO",
+ "date":"2017-11-12T16:01:34",
+ "fav":13,
+ "module":"JSON::Tiny",
+ "version":"0.58"
+ },
+ {
+ "author":"MLEHMANN",
+ "date":"2020-10-27T18:06:42",
+ "fav":108,
+ "module":"JSON::XS",
+ "version":"4.03"
+ },
+ {
+ "author":"LBROCARD",
+ "date":"2011-08-05T06:41:39",
+ "fav":2,
+ "module":"JSON::YAJL",
+ "version":"0.10"
+ },
+ {
+ "author":"SRI",
+ "date":"2020-12-30T14:43:19",
+ "fav":435,
+ "module":"Mojo::JSON",
+ "version":"8.70"
+ },
+ {
+ "author":"ETHER",
+ "date":"2015-06-10T04:38:55",
+ "fav":5,
+ "module":"JSON::Any",
+ "version":"1.39"
+ },
+ {
+ "author":"ETHER",
+ "date":"2020-11-13T04:34:16",
+ "fav":43,
+ "module":"JSON::MaybeXS",
+ "version":"1.004003"
+ },
+ {
+ "author":"LBROCARD",
+ "date":"2008-02-13T09:47:27",
+ "fav":0,
+ "module":"JSON::XS::VersionOneAndTwo",
+ "version":"0.31"
+ },
+ {
+ "author":"DBOOK",
+ "date":"2019-08-07T17:02:05",
+ "fav":8,
+ "module":"Mojo::JSON::MaybeXS",
+ "version":"1.002"
+ },
+ {
+ "author":"AKIYM",
+ "date":"2019-08-07T21:53:49",
+ "fav":0,
+ "module":"Test2::Tools::JSON",
+ "version":"0.05"
+ },
+ {
+ "author":"MOTEMEN",
+ "date":"2018-04-24T11:24:46",
+ "fav":5,
+ "module":"Test::Deep::JSON",
+ "version":"0.05"
+ },
+ {
+ "author":"OVID",
+ "date":"2009-08-09T09:20:24",
+ "fav":4,
+ "module":"Test::JSON",
+ "version":"0.11"
+ },
+ {
+ "author":"VOJ",
+ "date":"2012-09-14T14:38:20",
+ "fav":0,
+ "module":"Test::JSON::Entails",
+ "version":"0.2"
+ },
+ {
+ "author":"BAYASHI",
+ "date":"2016-04-28T01:29:13",
+ "fav":0,
+ "module":"Test::JSON::More",
+ "version":"0.02"
+ },
+ {
+ "author":"AEREAL",
+ "date":"2015-10-26T10:54:03",
+ "fav":0,
+ "module":"JSON::TypeInference",
+ "version":"v1.0.2"
+ },
+ {
+ "author":"TYPESTER",
+ "date":"2012-10-17T04:37:16",
+ "fav":3,
+ "module":"JSON::Types",
+ "version":"0.05"
+ },
+ {
+ "author":"PINE",
+ "date":"2017-04-01T11:08:58",
+ "fav":0,
+ "module":"JSON::Types::Flexible",
+ "version":"0.03"
+ },
+ {
+ "author":"RJBS",
+ "date":"2019-12-26T19:23:05",
+ "fav":1,
+ "module":"JSON::Typist",
+ "version":"0.006"
+ },
+ {
+ "author":"DOLMEN",
+ "date":"2015-03-04T23:40:22",
+ "fav":2,
+ "module":"App::JSON::to",
+ "version":"1.000"
+ },
+ {
+ "author":"INGY",
+ "date":"2016-07-08T17:14:57",
+ "fav":14,
+ "module":"boolean",
+ "version":"0.46"
+ },
+ {
+ "author":"RIZEN",
+ "date":"2014-12-25T23:07:43",
+ "fav":0,
+ "module":"Config::JSON",
+ "version":"1.5202"
+ },
+ {
+ "author":"DOLMEN",
+ "date":"2017-09-03T04:54:00",
+ "fav":3,
+ "module":"Devel::JSON",
+ "version":"1.001"
+ },
+ {
+ "author":"KILNA",
+ "date":"2012-07-27T18:49:38",
+ "fav":0,
+ "module":"Inline::JSON",
+ "version":"v1.0.4"
+ },
+ {
+ "author":"KNI",
+ "date":"2015-04-16T14:27:05",
+ "fav":0,
+ "module":"JSON::Builder",
+ "version":"0.04"
+ },
+ {
+ "author":"PERLANCAR",
+ "date":"2020-06-09T10:44:00",
+ "fav":3,
+ "module":"JSON::Color",
+ "version":"0.130"
+ },
+ {
+ "author":"GETTY",
+ "date":"2014-09-11T19:58:20",
+ "fav":3,
+ "module":"JSON_File",
+ "version":"0.004"
+ },
+ {
+ "author":"TOBYINK",
+ "date":"2020-01-27T09:22:15",
+ "fav":0,
+ "module":"JSON::MultiValueOrdered",
+ "version":"0.006"
+ },
+ {
+ "author":"BRUMMETT",
+ "date":"2015-02-04T20:19:07",
+ "fav":0,
+ "module":"JSON::String",
+ "version":"v0.2.0"
+ },
+ {
+ "author":"SOJIRO",
+ "date":"2016-02-24T22:29:12",
+ "fav":1,
+ "module":"JSON::MergePatch",
+ "version":"0.04"
+ },
+ {
+ "author":"MIXAS",
+ "date":"2018-10-25T21:09:47",
+ "fav":0,
+ "module":"JSON::Patch",
+ "version":"0.04"
+ },
+ {
+ "author":"POPEFELIX",
+ "date":"2018-05-05T03:35:34",
+ "fav":8,
+ "module":"JSON::Path",
+ "version":"0.420"
+ },
+ {
+ "author":"ZIGOROU",
+ "date":"2015-08-13T09:04:33",
+ "fav":2,
+ "module":"JSON::Pointer",
+ "version":"0.07"
+ },
+ {
+ "author":"TOBYINK",
+ "date":"2014-09-28T07:42:10",
+ "fav":1,
+ "module":"JSON::T",
+ "version":"0.104"
+ },
+ {
+ "author":"ETJ",
+ "date":"2020-01-01T15:21:38",
+ "fav":1,
+ "module":"JSON::Transform",
+ "version":"0.03"
+ },
+ {
+ "author":"PHAYLON",
+ "date":"2014-12-10T02:45:53",
+ "fav":1,
+ "module":"JSON::Diffable",
+ "version":"0.000002"
+ },
+ {
+ "author":"MIKO",
+ "date":"2016-04-30T18:37:10",
+ "fav":0,
+ "module":"JSON::Relaxed",
+ "version":"0.05"
+ },
+ {
+ "author":"INGY",
+ "date":"2020-04-27T15:52:03",
+ "fav":3,
+ "module":"JSONY",
+ "version":"v0.1.21"
+ },
+ {
+ "author":"GFRANKS",
+ "date":"2019-07-01T13:30:46",
+ "fav":1,
+ "module":"JSON::API",
+ "version":"v1.1.1"
+ },
+ {
+ "author":"SKINGTON",
+ "date":"2018-05-11T18:29:32",
+ "fav":1,
+ "module":"LWP::JSON::Tiny",
+ "version":"0.014"
+ },
+ {
+ "author":"ANTIPASTA",
+ "date":"2015-05-27T19:06:36",
+ "fav":8,
+ "module":"WWW::JSON",
+ "version":"1.02"
+ },
+ {
+ "author":"MAXMIND",
+ "date":"2015-04-01T20:10:25",
+ "fav":0,
+ "module":"JSON::XS::Sugar",
+ "version":"1.01"
+ },
+ {
+ "author":"DROLSKY",
+ "date":"2011-09-19T16:45:33",
+ "fav":2,
+ "module":"Silki::JSON",
+ "version":"0.29"
+ },
+ {
+ "author":"PERLANCAR",
+ "date":"2014-08-27T16:03:43",
+ "fav":0,
+ "module":"JSON::Decode::Marpa",
+ "version":"0.02"
+ },
+ {
+ "author":"PERLANCAR",
+ "date":"2018-03-25T12:23:33",
+ "fav":0,
+ "module":"JSON::Decode::Regexp",
+ "version":"0.101"
+ },
+ {
+ "author":"RSAVAGE",
+ "date":"2019-06-18T06:20:04",
+ "fav":0,
+ "module":"MarpaX::Demo::JSONParser",
+ "version":"1.08"
+ },
+ {
+ "author":"INGY",
+ "date":"2020-01-22T21:21:37",
+ "fav":0,
+ "module":"Pegex::JSON",
+ "version":"0.31"
+ },
+ {
+ "author":"KABLAMO",
+ "date":"2016-08-05T14:51:20",
+ "fav":0,
+ "module":"App::JSON::Tools",
+ "version":"0.01"
+ },
+ {
+ "author":"MSTROUT",
+ "date":"2011-02-02T00:09:45",
+ "fav":6,
+ "module":"App::JSONPretty",
+ "version":"1"
+ },
+ {
+ "author":"MOTEMEN",
+ "date":"2013-12-18T01:24:28",
+ "fav":1,
+ "module":"ARGV::JSON",
+ "version":"0.01"
+ },
+ {
+ "author":"AKXLIX",
+ "date":"2014-01-25T12:23:27",
+ "fav":1,
+ "module":"Haineko::JSON",
+ "version":"v0.2.16"
+ },
+ {
+ "author":"INGY",
+ "date":"2008-08-30T03:41:24",
+ "fav":0,
+ "module":"JS::JSON",
+ "version":"0.02"
+ },
+ {
+ "author":"SGREEN",
+ "date":"2017-07-07T05:50:07",
+ "fav":0,
+ "module":"JSON::Assert",
+ "version":"0.08"
+ },
+ {
+ "author":"TOBYINK",
+ "date":"2019-10-27T22:23:49",
+ "fav":0,
+ "module":"JSON::Eval",
+ "version":"0.002"
+ },
+ {
+ "author":"MAJENSEN",
+ "date":"2019-07-13T14:43:46",
+ "fav":3,
+ "module":"JSON::ize",
+ "version":"0.202"
+ },
+ {
+ "author":"HOEKIT",
+ "date":"2016-04-23T03:25:28",
+ "fav":0,
+ "module":"JSON::JSend",
+ "version":"0.02"
+ },
+ {
+ "author":"LNATION",
+ "date":"2020-10-25T12:34:39",
+ "fav":1,
+ "module":"JSON::Lines",
+ "version":"0.03"
+ },
+ {
+ "author":"ZOFFIX",
+ "date":"2015-11-28T13:52:07",
+ "fav":2,
+ "module":"JSON::Meth",
+ "version":"1.001007"
+ },
+ {
+ "author":"EWILHELM",
+ "date":"2013-06-26T22:29:17",
+ "fav":0,
+ "module":"JSON::ON",
+ "version":"v0.0.3"
+ },
+ {
+ "author":"MNUNBERG",
+ "date":"2017-11-10T14:09:31",
+ "fav":3,
+ "module":"JSON::SL",
+ "version":"v1.0.7"
+ },
+ {
+ "author":"MART",
+ "date":"2012-11-24T21:17:51",
+ "fav":3,
+ "module":"JSON::Streaming::Reader",
+ "version":"0.06"
+ },
+ {
+ "author":"MART",
+ "date":"2012-11-24T21:14:59",
+ "fav":0,
+ "module":"JSON::Streaming::Writer",
+ "version":"0.03"
+ },
+ {
+ "author":"JKUTEJ",
+ "date":"2015-09-03T16:00:14",
+ "fav":0,
+ "module":"JSON::Util",
+ "version":"0.06"
+ },
+ {
+ "author":"CINDY",
+ "date":"2020-04-18T02:49:16",
+ "fav":1,
+ "module":"JSON::XS::ByteString",
+ "version":"1.004"
+ },
+ {
+ "author":"DAEMON",
+ "date":"2017-05-02T05:16:57",
+ "fav":0,
+ "module":"Text::JSON::Nibble",
+ "version":"1.01"
+ }
+]
diff --git a/t/bugzilla-2049.t b/t/bugzilla-2049.t
index 36a0c72..a8e36b5 100644
--- a/t/bugzilla-2049.t
+++ b/t/bugzilla-2049.t
@@ -1,10 +1,10 @@
use warnings;
use strict;
use Test::More;
-use JSON::Parse 'json_file_to_perl';
+use JSON::Parse 'read_json';
eval {
-my $type = '';
-my $tri2file = json_file_to_perl ('$type-tri2file.txt');
+ my $type = '';
+ my $tri2file = read_json ('$type-tri2file.txt');
};
ok ($@);
note ($@);
diff --git a/t/read-file.t b/t/read-file.t
index f265d49..e3fb532 100644
--- a/t/read-file.t
+++ b/t/read-file.t
@@ -3,7 +3,9 @@ use warnings;
use strict;
use Test::More;
use FindBin '$Bin';
-use JSON::Parse 'json_file_to_perl';
+use JSON::Parse qw!read_json json_file_to_perl!;
my $p = json_file_to_perl ("$Bin/test.json");
ok ($p->{distribution} eq 'Algorithm-NGram');
+my $q = read_json ("$Bin/test.json");
+ok ($q->{distribution} eq 'Algorithm-NGram');
done_testing ();
diff --git a/t/string-bug-44.t b/t/string-bug-44.t
index 74c45d0..1c16853 100755
--- a/t/string-bug-44.t
+++ b/t/string-bug-44.t
@@ -4,7 +4,7 @@ use strict;
use utf8;
use FindBin '$Bin';
use Test::More;
-use JSON::Parse 'json_file_to_perl';
-my $in = json_file_to_perl ("$Bin/string-bug-44.json");
+use JSON::Parse 'read_json';
+my $in = read_json ("$Bin/string-bug-44.json");
cmp_ok (length ($in->{x}), '==', 4080, "Length as expected");
done_testing ();
diff --git a/t/syntax.t b/t/syntax.t
index 9288d5b..fc7bf9d 100644
--- a/t/syntax.t
+++ b/t/syntax.t
@@ -5,9 +5,9 @@ use warnings;
use strict;
use FindBin '$Bin';
use Test::More;
-use JSON::Parse 'json_file_to_perl';
+use JSON::Parse 'read_json';
eval {
- my $json = json_file_to_perl ("$Bin/syntax-error-1.json");
+ my $json = read_json ("$Bin/syntax-error-1.json");
};
note ($@);
ok (! $@);