Hello community,
here is the log from the commit of package perl-Cpanel-JSON-XS for
openSUSE:Factory checked in at 2019-02-19 12:03:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Cpanel-JSON-XS (Old)
and /work/SRC/openSUSE:Factory/.perl-Cpanel-JSON-XS.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Cpanel-JSON-XS"
Tue Feb 19 12:03:03 2019 rev:16 rq:677225 version:4.09
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Cpanel-JSON-XS/perl-Cpanel-JSON-XS.changes
2018-12-12 17:26:49.551003182 +0100
+++
/work/SRC/openSUSE:Factory/.perl-Cpanel-JSON-XS.new.28833/perl-Cpanel-JSON-XS.changes
2019-02-19 12:03:11.893051480 +0100
@@ -1,0 +2,12 @@
+Sat Feb 16 06:07:20 UTC 2019 - Stephan Kulow <[email protected]>
+
+- updated to 4.09
+ see /usr/share/doc/packages/perl-Cpanel-JSON-XS/Changes
+
+ 4.09 2019-02-15 (rurban)
+ - Add seperate allow_dupkeys property, in relaxed (#122)
+ - Fixed allow_dupkeys for the XS slow path
+ - Silence 2 -Wunused-value warnings
+ - Fix ->unblessed_bool to produce modifiable perl structures (PR
#121 by Pali)
+
+-------------------------------------------------------------------
Old:
----
Cpanel-JSON-XS-4.08.tar.gz
New:
----
Cpanel-JSON-XS-4.09.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Cpanel-JSON-XS.spec ++++++
--- /var/tmp/diff_new_pack.n5JI1S/_old 2019-02-19 12:03:12.757051040 +0100
+++ /var/tmp/diff_new_pack.n5JI1S/_new 2019-02-19 12:03:12.761051037 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Cpanel-JSON-XS
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: perl-Cpanel-JSON-XS
-Version: 4.08
+Version: 4.09
Release: 0
%define cpan_name Cpanel-JSON-XS
Summary: Cpanel Fork of Json::Xs, Fast and Correct Serializing
++++++ Cpanel-JSON-XS-4.08.tar.gz -> Cpanel-JSON-XS-4.09.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/Changes
new/Cpanel-JSON-XS-4.09/Changes
--- old/Cpanel-JSON-XS-4.08/Changes 2018-11-28 12:07:28.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/Changes 2019-02-15 11:08:46.000000000 +0100
@@ -2,6 +2,12 @@
TODO: http://stevehanov.ca/blog/index.php?id=104 compression
+4.09 2019-02-15 (rurban)
+ - Add seperate allow_dupkeys property, in relaxed (#122)
+ - Fixed allow_dupkeys for the XS slow path
+ - Silence 2 -Wunused-value warnings
+ - Fix ->unblessed_bool to produce modifiable perl structures (PR #121
by Pali)
+
4.08 2018-11-28 (rurban)
- Add unblessed_bool property (PR #118 by Pali)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/META.json
new/Cpanel-JSON-XS-4.09/META.json
--- old/Cpanel-JSON-XS-4.08/META.json 2018-11-28 15:25:44.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/META.json 2019-02-15 11:09:20.000000000 +0100
@@ -4,7 +4,7 @@
"Reini Urban <[email protected]>"
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter
version 2.150010",
+ "generated_by" : "ExtUtils::MakeMaker version 8.3506, CPAN::Meta::Converter
version 2.150010",
"license" : [
"perl_5"
],
@@ -48,7 +48,7 @@
"url" : "https://github.com/rurban/Cpanel-JSON-XS"
}
},
- "version" : "4.08",
+ "version" : "4.09",
"x_contributors" : [
"Ashley Willis <[email protected]>",
"Daniel Dragan <[email protected]>",
@@ -73,5 +73,5 @@
"Sergey Aleynikov <[email protected]>",
"Syohei Yoshida <[email protected]>"
],
- "x_serialization_backend" : "JSON::PP version 2.97001"
+ "x_serialization_backend" : "JSON::PP version 2.97001_04"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/META.yml
new/Cpanel-JSON-XS-4.09/META.yml
--- old/Cpanel-JSON-XS-4.08/META.yml 2018-11-28 15:25:44.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/META.yml 2019-02-15 11:09:20.000000000 +0100
@@ -7,7 +7,7 @@
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version
2.150010'
+generated_by: 'ExtUtils::MakeMaker version 8.3506, CPAN::Meta::Converter
version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -23,7 +23,7 @@
bugtracker: https://github.com/rurban/Cpanel-JSON-XS/issues
license: http://dev.perl.org/licenses/
repository: https://github.com/rurban/Cpanel-JSON-XS
-version: '4.08'
+version: '4.09'
x_contributors:
- 'Ashley Willis <[email protected]>'
- 'Daniel Dragan <[email protected]>'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/README
new/Cpanel-JSON-XS-4.09/README
--- old/Cpanel-JSON-XS-4.08/README 2018-11-28 15:25:46.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/README 2019-02-15 11:09:21.000000000 +0100
@@ -553,12 +553,12 @@
{ foo:"bar" }
- * duplicate keys
+ * allow_dupkeys
- With relaxed decoding of duplicate keys does not error and are
- silently accepted. See <http://seriot.ch/parsing_json.php#24>:
+ Allow decoding of duplicate keys in hashes. By default duplicate
+ keys are forbidden. See <http://seriot.ch/parsing_json.php#24>:
RFC 7159 section 4: "The names within an object should be
- unique."
+ unique." See the "allow_dupkeys" option.
$json = $json->canonical ([$enable])
$enabled = $json->get_canonical
@@ -704,6 +704,20 @@
This option is special to this module, it is not supported by other
encoders. So it is not recommended to use it.
+ $json = $json->allow_dupkeys ([$enable])
+ $enabled = $json->get_allow_dupkeys
+ If $enable is true (or missing), then the "decode" method will not
+ die when it encounters duplicate keys in a hash. "allow_dupkeys" is
+ also enabled in the "relaxed" mode.
+
+ The JSON spec allows duplicate name in objects but recommends to
+ disable it, however with Perl hashes they are impossible, parsing
+ JSON in Perl silently ignores duplicate names, using the last value
+ found.
+
+ See <http://seriot.ch/parsing_json.php#24>: RFC 7159 section 4: "The
+ names within an object should be unique."
+
$json = $json->allow_blessed ([$enable])
$enabled = $json->get_allow_blessed
If $enable is true (or missing), then the "encode" method will not
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/SIGNATURE
new/Cpanel-JSON-XS-4.09/SIGNATURE
--- old/Cpanel-JSON-XS-4.08/SIGNATURE 2018-11-28 15:25:45.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/SIGNATURE 2019-02-15 11:09:21.000000000 +0100
@@ -12,19 +12,19 @@
not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA256
+Hash: SHA512
SHA256 0abb585f231403618cae65047cfb3910d018ec83951b2bc14dcef5cbc77d1151
.appveyor.yml
SHA256 797abf38891d61e631374ccba78b2a8a707901227012c59372f5a9b2bc867188
.travis.yml
SHA256 8de3540a3cd7ecc9a9dcb48975fe852c082fe17d4462f87bb72aa7cc47f083ad COPYING
-SHA256 272c063480cb84cbe62d0cfcb7f96e5ee89efd16216b89e27e76b6c6f12910fa Changes
+SHA256 522decc91c620d5f84df5360910d62b3994245947ce35ba035ef838c666eb4da Changes
SHA256 04d51042e2091c8c1f22252efa7e11322d2f6c4dc60c5145aec77e2969f506c8
MANIFEST
-SHA256 5702c884dfd5e88c693eca4e260a262b36e623517707ca4f74c2eb61fe579fbe
META.json
-SHA256 a38872f0e1dad9ed2081becd2ab31553eb7803b530e759b4aee85f0add1a9d57
META.yml
+SHA256 2ef7507495b63c0b94e5540f04bdb558e6fe69f274b7cc75aa0ebedaf9c1b3d4
META.json
+SHA256 6ebd91bec619d542fa2e5d4d441e1d9dcb2adafac67fc7426dc08bba90bfab74
META.yml
SHA256 d718ee16b2c401c39ce7e2aa2262d4950498879764e060506ed8d667d0a4b798
Makefile.PL
-SHA256 d31515d9bc0b76a3990f312e0c33e1072ea66541231da9d7beb0a9e92b1a196f README
-SHA256 57c0b1143b936a907c09fe1711f59d0ca97ea856bc5395ca3f040a27b938e697 XS.pm
-SHA256 501b26001f9d7bb3d26386ed3e827c95272ee4c50f0fb19508cd0165395a7afb XS.xs
+SHA256 599983808ff085fb2e2ec6021e56bac1ffddf315cefb1450e5d58e7687d793a9 README
+SHA256 8c19dea1751d4d95c7ebea43b748063603d9fcbcf45c7cf5a187016c1febe190 XS.pm
+SHA256 4a992ffcf7f5b39f9fa209ca3f43e02fd4b19ab72a958c99743228c28b4bc0a0 XS.xs
SHA256 c95e4b970183cbd6d1ec9c88c37a80f12bd2b66ed6be3c008ffd578d2f622c01
XS/Boolean.pm
SHA256 f9a40fece0783df5c1d1d3d6f2586e61689b0445dcf10bba2916553c29d5f490
XS/Type.pm
SHA256 2f34a530b7ce981b0df9aacd2b6944ccf74c4a7f8bb49fde57b342663e7feb26
bin/cpanel_json_xs
@@ -71,8 +71,8 @@
SHA256 3da823eab55abb6dca05e8bc6111d3b59ea18c4ee270baf6413d9a45042ff48c
t/22_comment_at_eof.t
SHA256 2a6506fb07b27b1fef52b251d3876d23bd572596ff487d37c2f6597be554836c
t/23_array_ctx.t
SHA256 a8dfccba0b60b0fc91812fcfd96656e993abb74970509926d738c67a58641f01
t/24_freeze_recursion.t
-SHA256 016500c1aa6878e4329f3b7ed110a4a6aa90a80fa4350161f9b8fe107d8b9346
t/25_boolean.t
-SHA256 138c912f350075b8a9dcd6a8810cb3c40b3e8ac11ae804ef167cc0d7d0773798
t/26_duplicate.t
+SHA256 b35b52310a4c3edfcb2653f681aa7a42712cf93a0a8d66729544996bdcf9ce06
t/25_boolean.t
+SHA256 25d388275acde51b3d768b80c7a4b03d47988cc3919c81aa71b657250b5d4099
t/26_duplicate.t
SHA256 03a2061b4742ea591961a4ce7403feac91998c0909dbde982c465ce3d2c39706
t/30_jsonspec.t
SHA256 f31d07044b924b28a1329f9eac213ad903ec4b8bb6eda095a609cb8c87870439
t/31_bom.t
SHA256 59c743137453c8c4e9e785a15dcd057b0209d5ce160d683d7ab416dc37a92b6d
t/52_object.t
@@ -437,12 +437,12 @@
SHA256 aca6f846869ab2e4881e807739086e1535b1438bd0e23d7a021360742736a6a9
xt/pod.t
-----BEGIN PGP SIGNATURE-----
-iQEzBAEBCAAdFiEEKJWogdNCcPq/6PdHtPYzOeZdZBQFAlv+pWkACgkQtPYzOeZd
-ZBRHfAf+P0oWTSct+ILbGE2/X17Y4fFwKWOG0PNDlDiaHoF+tEh9tsmwziSawJ8K
-65AdjnXWmMNEdFOQjJpgRght7fgAoW7D9yv2banqMiCnVNCDfVPWTqsKUaI1zgBq
-+Bk58Hl7tcTer72P8OtA+VVY9AKk3kgMJxOb9wN2zDASiMlMEsPJiC6TugKLMnuc
-vlmSDTK3LCjAoQXhNR7a2nXZaPO04NxzRXy7k6UDnte7KJUB60Uu0TgqOApgPc1n
-o4UbTTddJ+J+qsLRG+FTs7A9oWY+Z15lEdv9lgrKCNnZv6VAPN/w9Gs/O8m3TJua
-7WD7YWc38c1+0qnvNmH05zwUUzoe1w==
-=oV3y
+iQEzBAEBCgAdFiEEKJWogdNCcPq/6PdHtPYzOeZdZBQFAlxmj9EACgkQtPYzOeZd
+ZBRqnwf7B5jRgiv04q3+bVuH3MLlfIOf6JOU0/ilSjuZJw/6/xesPq7HdNCxbpRW
+pqBa7fQ0ak/dkFpImIVIVVdJbsTO9Ye5T5jExHZ/PTJHMmnI4GD1yUnbFZrl+enO
+tdhWV91564kpGqMeDM55IKBs4VBVpL0VTF0oNlN/kgBCbDdkwrE7nuIpcqiLEFE9
+rS4vYbTKj6JpoiDnTdKrJCax82cteY7NW1CSvYgbl74KrWsWuAfe2WX1VqmUCUzP
+uCTV7Fr/wZybTbpfH6XFr4G4V7gw25DOyR9FNYUYPWl/irleEYTlDBxb96xDLiD4
+dPwtVrVX9xX6wRXYpjt07MAyrRkMsw==
+=BMPR
-----END PGP SIGNATURE-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/XS.pm
new/Cpanel-JSON-XS-4.09/XS.pm
--- old/Cpanel-JSON-XS-4.08/XS.pm 2018-11-28 12:07:28.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/XS.pm 2019-02-15 11:08:46.000000000 +0100
@@ -1,5 +1,5 @@
package Cpanel::JSON::XS;
-our $VERSION = '4.08';
+our $VERSION = '4.09';
our $XS_VERSION = $VERSION;
# $VERSION = eval $VERSION;
@@ -645,11 +645,12 @@
{ foo:"bar" }
-=item * duplicate keys
+=item * allow_dupkeys
-With relaxed decoding of duplicate keys does not error and are silently
accepted.
+Allow decoding of duplicate keys in hashes. By default duplicate keys are
forbidden.
See L<http://seriot.ch/parsing_json.php#24>:
RFC 7159 section 4: "The names within an object should be unique."
+See the L</allow_dupkeys> option.
=back
@@ -824,6 +825,22 @@
This option is special to this module, it is not supported by other
encoders. So it is not recommended to use it.
+=item $json = $json->allow_dupkeys ([$enable])
+
+=item $enabled = $json->get_allow_dupkeys
+
+If C<$enable> is true (or missing), then the C<decode> method will not
+die when it encounters duplicate keys in a hash.
+C<allow_dupkeys> is also enabled in the C<relaxed> mode.
+
+The JSON spec allows duplicate name in objects but recommends to
+disable it, however with Perl hashes they are impossible, parsing
+JSON in Perl silently ignores duplicate names, using the last value
+found.
+
+See L<http://seriot.ch/parsing_json.php#24>:
+RFC 7159 section 4: "The names within an object should be unique."
+
=item $json = $json->allow_blessed ([$enable])
=item $enabled = $json->get_allow_blessed
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/XS.xs
new/Cpanel-JSON-XS-4.09/XS.xs
--- old/Cpanel-JSON-XS-4.08/XS.xs 2018-11-28 12:07:28.000000000 +0100
+++ new/Cpanel-JSON-XS-4.09/XS.xs 2019-02-15 11:08:46.000000000 +0100
@@ -277,10 +277,11 @@
#define F_SORT_BY 0x00100000UL
#define F_ALLOW_STRINGIFY 0x00200000UL
#define F_UNBLESSED_BOOL 0x00400000UL
+#define F_ALLOW_DUPKEYS 0x00800000UL
#define F_HOOK 0x80000000UL /* some hooks exist, so slow-path
processing */
#define F_PRETTY F_INDENT | F_SPACE_BEFORE | F_SPACE_AFTER
-#define SET_RELAXED (F_RELAXED | F_ALLOW_BAREKEY | F_ALLOW_SQUOTE)
+#define SET_RELAXED (F_RELAXED | F_ALLOW_BAREKEY | F_ALLOW_SQUOTE |
F_ALLOW_DUPKEYS)
#define INIT_SIZE 32 /* initial scalar size to be allocated */
#define INDENT_STEP 3 /* default spaces per indentation level */
@@ -3254,7 +3255,7 @@
SV *typerv;
int allow_squote = dec->json.flags & F_ALLOW_SQUOTE;
int allow_barekey = dec->json.flags & F_ALLOW_BAREKEY;
- int relaxed = dec->json.flags & F_RELAXED;
+ int allow_dupkeys = dec->json.flags & F_ALLOW_DUPKEYS;
char endstr = '"';
DEC_INC_DEPTH;
@@ -3314,14 +3315,16 @@
if (!key)
goto fail;
+ if (!allow_dupkeys && UNLIKELY(hv_exists_ent (hv, key, 0))) {
+ ERR ("Duplicate keys not allowed");
+ }
decode_ws (dec); EXPECT_CH (':');
-
decode_ws (dec);
if (typesv)
{
value_typesv = newSV (0);
- hv_store_ent (typehv, key, value_typesv, 0);
+ (void)hv_store_ent (typehv, key, value_typesv, 0);
}
value = decode_sv (aTHX_ dec, value_typesv);
@@ -3331,7 +3334,7 @@
goto fail;
}
- hv_store_ent (hv, key, value, 0);
+ (void)hv_store_ent (hv, key, value, 0);
SvREFCNT_dec (key);
break;
@@ -3351,14 +3354,12 @@
if (UNLIKELY(p - key > I32_MAX))
ERR ("Hash key too large");
#endif
- if (!relaxed && UNLIKELY(hv_exists (hv, key, len))) {
+ if (!allow_dupkeys && UNLIKELY(hv_exists (hv, key, len))) {
ERR ("Duplicate keys not allowed");
}
dec->cur = p + 1;
-
decode_ws (dec); if (*p != ':') EXPECT_CH (':');
-
decode_ws (dec);
if (typesv)
@@ -3602,7 +3603,7 @@
if (typesv)
sv_setiv_mg (typesv, JSON_TYPE_BOOL);
if (dec->json.flags & F_UNBLESSED_BOOL)
- return &PL_sv_yes;
+ return newSVsv (&PL_sv_yes);
return newSVsv(MY_CXT.json_true);
}
else
@@ -3618,7 +3619,7 @@
if (typesv)
sv_setiv_mg (typesv, JSON_TYPE_BOOL);
if (dec->json.flags & F_UNBLESSED_BOOL)
- return &PL_sv_no;
+ return newSVsv (&PL_sv_no);
return newSVsv(MY_CXT.json_false);
}
else
@@ -4109,6 +4110,7 @@
escape_slash = F_ESCAPE_SLASH
allow_stringify = F_ALLOW_STRINGIFY
unblessed_bool = F_UNBLESSED_BOOL
+ allow_dupkeys = F_ALLOW_DUPKEYS
PPCODE:
if (enable)
self->flags |= ix;
@@ -4137,8 +4139,9 @@
get_allow_singlequote = F_ALLOW_SQUOTE
get_allow_bignum = F_ALLOW_BIGNUM
get_escape_slash = F_ESCAPE_SLASH
- get_allow_stringify = F_ALLOW_STRINGIFY
+ get_allow_stringify = F_ALLOW_STRINGIFY
get_unblessed_bool = F_UNBLESSED_BOOL
+ get_allow_dupkeys = F_ALLOW_DUPKEYS
PPCODE:
XPUSHs (boolSV (self->flags & ix));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/t/25_boolean.t
new/Cpanel-JSON-XS-4.09/t/25_boolean.t
--- old/Cpanel-JSON-XS-4.08/t/25_boolean.t 2018-11-28 12:07:29.000000000
+0100
+++ new/Cpanel-JSON-XS-4.09/t/25_boolean.t 2019-02-15 11:07:11.000000000
+0100
@@ -1,5 +1,5 @@
use strict;
-use Test::More tests => 40;
+use Test::More tests => 42;
use Cpanel::JSON::XS ();
use Config;
@@ -113,5 +113,9 @@
cmp_ok($js->{is_false}, "==", 0, "->unblessed_bool for JSON false returns
correct Perl bool value");
cmp_ok($js->{is_false}, "eq", "", "->unblessed_bool for JSON false returns
correct Perl bool value");
-is($unblessed_bool_cjson->encode($unblessed_bool_cjson->decode($truefalse)),
$truefalse, "encode(decode(boolean)) is identity with ->unblessed_bool");
-is($cjson->encode($unblessed_bool_cjson->decode($truefalse)), $truefalse,
"booleans decoded by ->unblessed_bool(1) are encoded by ->unblessed_bool(0) in
the same way");
+is($unblessed_bool_cjson->encode(do { my $struct =
$unblessed_bool_cjson->decode($truefalse, my $types); ($struct, $types) }),
$truefalse, "encode(decode(boolean)) is identity with ->unblessed_bool");
+is($cjson->encode(do { my $struct = $unblessed_bool_cjson->decode($truefalse,
my $types); ($struct, $types) }), $truefalse, "booleans decoded by
->unblessed_bool(1) are encoded by ->unblessed_bool(0) in the same way");
+
+$js = $unblessed_bool_cjson->decode($truefalse);
+ok eval { $js->[0] = "new value 0" }, "decoded 'true' is modifiable" or
diag($@);
+ok eval { $js->[1] = "new value 1" }, "decoded 'false' is modifiable" or
diag($@);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Cpanel-JSON-XS-4.08/t/26_duplicate.t
new/Cpanel-JSON-XS-4.09/t/26_duplicate.t
--- old/Cpanel-JSON-XS-4.08/t/26_duplicate.t 2018-06-21 13:18:27.000000000
+0200
+++ new/Cpanel-JSON-XS-4.09/t/26_duplicate.t 2019-02-15 11:08:46.000000000
+0100
@@ -1,13 +1,38 @@
-use Test::More tests => 4;
+use strict;
+use Test::More tests => 9;
use Cpanel::JSON::XS;
my $json = Cpanel::JSON::XS->new;
-# disallow dupkeys:
+# disallow dupkeys
ok (!eval { $json->decode ('{"a":"b","a":"c"}') }); #
y_object_duplicated_key.json
ok (!eval { $json->decode ('{"a":"b","a":"b"}') }); #
y_object_duplicated_key_and_value.json
+# relaxed allows dupkeys
$json->relaxed;
-is (encode_json ($json->decode ('{"a":"b","a":"c"}')), '{"a":"c"}'); #
y_object_duplicated_key.json
-is (encode_json ($json->decode ('{"a":"b","a":"b"}')), '{"a":"b"}'); #
y_object_duplicated_key_and_value.json
+# y_object_duplicated_key.json
+is (encode_json ($json->decode ('{"a":"b","a":"c"}')), '{"a":"c"}', 'relaxed');
+# y_object_duplicated_key_and_value.json
+is (encode_json ($json->decode ('{"a":"b","a":"b"}')), '{"a":"b"}', 'relaxed');
+# turning off relaxed disallows dupkeys
+$json->relaxed(0);
+$json->allow_dupkeys; # but turn it on
+is (encode_json ($json->decode ('{"a":"b","a":"c"}')), '{"a":"c"}',
'allow_dupkeys');
+is (encode_json ($json->decode ('{"a":"b","a":"b"}')), '{"a":"b"}',
'allow_dupkeys');
+
+# disallow dupkeys explicitly
+$json->allow_dupkeys(0);
+eval { $json->decode ('{"a":"b","a":"c"}') };
+like ($@, qr/^Duplicate keys not allowed/, 'allow_dupkeys(0)');
+
+# disallow dupkeys explicitly with relaxed
+$json->relaxed;
+$json->allow_dupkeys(0);
+eval { $json->decode ('{"a":"b","a":"c"}') }; # the XS slow path
+like ($@, qr/^Duplicate keys not allowed/, 'relaxed and allow_dupkeys(0)');
+
+$json->allow_dupkeys;
+$json->relaxed(0); # tuning off relaxed needs to turn off dupkeys
+eval { $json->decode ('{"a":"b","a":"c"}') };
+like ($@, qr/^Duplicate keys not allowed/, 'relaxed(0)');