JSON-XS
view release on metacpan or search on metacpan
TODO: investigate magic (Eric Brine)
TODO: [PATCH] Types::Serialiser: Inline true(), false() and error() functions
TODO: replace bool_stash by BOOL_STASH seems to work with mod_perl, make a compile time option?
TODO: https://github.com/ulfjack/ryu https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/ / https://github.com/lemire/fast_double_parser
TODO: validate_utf8, apparewntly some people confuse themselves.
TODO: security considerations
TODO: decode_av/hv can leak memory when exceptions through through.
TODO: perl 5.36 has builtin::true/false/is_bool. Not sure how to integrate those.
4.06 Wed 18 Nov 2026 08:32:16 CET
- a large number of CVEs were reported against Cpanel::JSON::XS,
which is a fork of this module, but CPANSec did not make
any report against JSON::XS for some reason. Here is a review
of these recently reported CVEs and if/how they apply to JSON::XS.
Thanks to everybdoy who reported these issues!
.
Bogus CVEs / not a vulnerability, but fixed in this version:
110682 - Incremental parsing of numbers depended on input
chunk boundaries.
110686 - Use-after-free when an object-filter callback
patch fixes the submitted reproducer while exceptions
still leak.
- fix ->boolean_values leaking memory (reported by Albert Gierlach).
- incremental parsing now waits for lookahead before returning
a number, to avoid prematurely ending a numeric JSON prefix
(should fix the same problem as reported in CVE-2026-110682).
Sidenote: I think the cpanel fix does not actually fix the CVE
at all, it simply makes numbers illegal by default, and when
enabled, still misparses them.
4.05 Fri 13 Nov 2026 05:21:06 CET
- the incremental parser would not properly reset parsing offset
after removing a top-level number json number, causing memory
corruption. this is potentially a very serious vulnerability.
(reported by Albert Gierlach).
- the ignore initial whitespace optimisation in the incremental
parser could result in the parser reading beyond the end of string,
potentially leading to parsing errors or skipping json texts.
- FREEZE method calls could move the stack and cause a use-after-free.
requires allow_tags and a suitable FREEZE method to be exploited
(reported by Albert Gierlach).
potentially causing stack overflow (reported by Peter Juhasz).
4.04 Fri 05 Sep 2025 23:59:48 CEST
- fix heap overflow causing crashes, possibly information
disclosure or worse (CVE-2025-40928), and causes JSON::XS to
accept invalid JSON texts as valid in some cases. Thanks to
Michael Hudak for finding this, the CPAN Security Group for
coordinating this, and Reini Urban for double-checking the patch
(and Peter Juhasz for potentially reporting this much earlier).
4.03 Tue Oct 27 19:05:01 CET 2020
- when parsing comments in relaxed mode, JSON::XS would detect garbage
after the JSON text if the comment is after the end and does not end in
a newline (reported by Felipe Gasper).
4.02 Wed Mar 6 08:31:24 CET 2019
- undo the fix from 4.01, it breaks more things than it fixes
(another testcase by Wesley Schwengle).
- try a proper fix this time.
4.01 Sun Feb 24 05:03:30 CET 2019
- fix some stack corruption caused mostly when calling methods
in list context (testcase by Wesley Schwengle).
4.0 Fri Nov 16 00:06:54 CET 2018
- SECURITY IMPLICATION: this release enables allow_nonref by default
for compatibility with RFC 7159 and newer. See "old" vs. "new"
JSON under SECURITY CONSIDERATIONS.
- reworked the "old" vs. "new" JSON section.
- add ->boolean_values to provide the values to which booleans
decode (requested by Aristotle Pagaltzis).
- decode would wrongly accept ASCII NUL characters instead of
reporting them as trailing garbage.
- work around what smells like a perl bug w.r.t. exceptions
thrown in callbacks.
- change exponential realloc algorithm on encoding and string decoding to be
really exponential (this helps slow/debugging allocators such as libumem)
(reported by Matthew Horsfall).
- string encoding would needlessly overallocate output space
(testcase by Matthew Horsfall).
- be very paranoid about extending buffer lengths and croak if buffers get too large,
which might (or might not) improve security.
- add cbor-packed type to json_xs.
- switch from YAML to YAML::XS in json_xs, as YAML is way too buggy and outdated.
3.03 Wed Nov 16 20:20:59 CET 2016
- fix a bug introduced by a perl bug workaround that would cause
incremental parsing to fail with a sv_chop panic.
- json_xs: toformat failure error message fixed.
- json_xs: allow cyclic data structures in CBOR.
3.02 Fri Feb 26 22:45:20 CET 2016
- allow_nonref now affects booleans (\1, $Types::Serialiser::Boolean)
as well (reported by Alex Efros).
- allow literal tabs in strings in relaxed mode (patch by
lubo.rintel@gooddata.com).
- support "cbor" format in json_xs tool.
- support (and fix) calling encode and decode in list context
(reported by Ðадим ÐлаÑов).
- work around a bug in older perls crashing when presented
with shared hash keys (Reini Urban).
- use stability canary.
3.01 Tue Oct 29 16:55:15 CET 2013
- backport to perls < 5.18 (reported by Paul Howarth).
3.0 Tue Oct 29 01:35:37 CET 2013
- implemented an object tagging extension (using the
Types::Serialiser serialisation protocol).
- reworked the documentation regarding object serialisation,
add a new OBJECT SERIALISATION section that explains th
whole process.
- new setting: allow_tags.
- switch to Types::Serialiser booleans.
- remove to_json/from_json.
- other minor improvements to the documentation.
(e.g. undef) when trying to decode a json text (reported
and analyzed by Goro Fuji).
2.3 Wed Aug 18 01:26:47 CEST 2010
- make sure decoder doesn't change the decoding in the incremental
parser (testcase provided by Hendrik Schumacher).
- applied patch by DaTa for Data::Dumper support in json_xs.
- added -t dump support to json_xs, using Data::Dump.
- added -f eval support to json_xs.
2.29 Wed Mar 17 02:39:12 CET 2010
- fix a memory leak when callbacks set using filter_json_object
or filter_json_single_key_object were called (great testcase
by Eric Wilhelm).
2.28 Thu Mar 11 20:30:46 CET 2010
- implement our own atof function - perl's can be orders of
magnitudes slower than even the system one. on the positive
side, ours seems to be more exact in general than perl's.
(testcase provided by Tim Meadowcroft).
- clarify floating point conversion issues a bit.
- update jpsykes csrf article url.
- updated benchmark section - JSON::PP became much faster!
2.27 Thu Jan 7 07:35:08 CET 2010
- support relaxed option inside the incremental parser
(testcase provided by IKEGAMI via Makamaka).
2.26 Sat Oct 10 03:26:19 CEST 2009
- big integers could become truncated (based on patch
by Strobl Anton).
- output format change: indent now adds a final newline, which is
more expected and more true to the documentation.
2.25 Sat Aug 8 12:04:41 CEST 2009
- require common sense.
2.24 Sat May 30 08:25:45 CEST 2009
- the incremental parser did not update its parse offset
pointer correctly when parsing utf8-strings (nicely
debugged by Martin Evans).
- appending a non-utf8-string to the incremental parser
in utf8 mode failed to upgrade the string.
- wording of parse error messages has been improved.
2.232 Sun Feb 22 11:12:25 CET 2009
- use an exponential algorithm to extend strings, to
help platforms with bad or abysmal==windows memory
allocater performance, at the expense of some memory
wastage (use shrink to recover this extra memory).
(nicely analysed by Dmitry Karasik).
2.2311 Thu Feb 19 02:12:54 CET 2009
- add a section "JSON and ECMAscript" to explain some
incompatibilities between the two (problem was noted by
various people).
- add t/20_faihu.t.
2.231 Thu Nov 20 04:59:08 CET 2008
- work around 5.10.0 magic bugs where manipulating magic values
(such as $1) would permanently damage them as perl would
ignore the magicalness, by making a full copy of the string,
reported by Dmitry Karasik.
- work around spurious warnings under older perl 5.8's.
2.23 Mon Sep 29 05:08:29 CEST 2008
- fix a compilation problem when perl is not using char * as, well,
char *.
- use PL_hexdigit in favour of rolling our own.
- added support for incremental json parsing (still EXPERIMENTAL).
- implemented and added a json_xs command line utility that can convert
from/to a number of serialisation formats - tell me if you need more.
- implement allow_unknown/get_allow_unknown methods.
- fixed documentation of max_depth w.r.t. higher and equal.
- moved down =encoding directive a bit, too much breaks if it's the first
pod directive :/.
- removed documentation section on other modules, it became somewhat
outdated and is nowadays mostly of historical interest.
2.1 Wed Mar 19 23:23:18 CET 2008
- update documentation here and there: add a large section
about utf8/latin1/ascii flags, add a security consideration
and extend and clarify the JSON and YAML section.
- medium speed enhancements when encoding/decoding non-ascii chars.
- minor speedup in number encoding case.
- extend and clarify the section on incompatibilities
between YAML and JSON.
- switch to static inline from just inline when using gcc.
- add =encoding utf-8 to the manpage, now that perl 5.10 supports it.
- fix some issues with UV to JSON conversion of unknown impact.
- published the yahoo locals search result used in benchmarks as the
original url changes so comparison is impossible.
2.01 Wed Dec 5 11:40:28 CET 2007
- INCOMPATIBLE API CHANGE: to_json and from_json have been
renamed to encode_json/decode_json for JSON.pm compatibility.
The old functions croak and might be replaced by JSON.pm
comaptible versions in some later release.
2.0 Tue Dec 4 11:30:46 CET 2007
- this is supposed to be the first version of JSON::XS
compatible with version 2.0+ of the JSON module.
Using the JSON module as frontend to JSON::XS should be
as fast as using JSON::XS directly, so consider using it
instead.
- added get_* methods for all "simple" options.
- make JSON::XS subclassable.
1.53 Tue Nov 13 23:58:33 CET 2007
- minor doc clarifications.
- fixed many doc typos (patch by Thomas L. Shinnick).
1.52 Mon Oct 15 03:22:06 CEST 2007
- remove =encoding pod directive again, it confuses too many pod
parsers :/.
1.51 Sat Oct 13 03:55:56 CEST 2007
- encode empty arrays/hashes in a compact way when pretty is enabled.
- apparently JSON::XS was used to find some bugs in the
send me his report, so I cannot ask about the stack limit on fbsd).
0.8 Mon Mar 26 00:10:48 CEST 2007
- fix a memleak when decoding hashes.
- export jsonToBj and objToJson as aliases
to to_json and from_json, to reduce incompatibilities
between JSON/JSON::PC and JSON::XS. (experimental).
- implement a maximum nesting depth for both en- and de-coding.
- added a security considerations sections.
0.7 Sun Mar 25 01:46:30 CET 2007
- code cleanup.
- fix a memory overflow bug when indenting.
- pretty-printing now up to 15% faster.
- improve decoding speed of strings by
up to 50% by specialcasing short strings.
- further decoding speedups for strings using
lots of \u escapes.
- improve utf8 decoding speed for U+80 .. U+7FF.
0.5 Sat Mar 24 20:41:51 CET 2007
- added the UTF-16 encoding example hinted at in previous
versions.
- minor documentation fixes.
- fix a bug in and optimise canonicalising fastpath
(reported by Craig Manley).
- remove a subtest that breaks with bleadperl (reported
by Andreas König).
0.31 Sat Mar 24 02:14:34 CET 2007
- documentation updates.
- do some casting to hopefully fix Andreas' problem.
- nuke bogus json rpc stuff.
0.3 Fri Mar 23 19:33:21 CET 2007
- remove spurious PApp::Util reference (John McNamara).
- adapted lots of tests from other json modules
(idea by Chris Carline).
- documented mapping from json to perl and vice versa.
- improved the documentation by adding more examples.
- added short escaping forms, reducing the created
json texts a bit.
- added shrink flag.
- when flag methods are called without enable argument
they will by default enable their flag.
with gcc 4).
- added a test that covers lots of different characters.
- clarified some error messages.
- error messages now use correct character offset
with F_UTF8.
- improve the "no bytes" and "no warnings" hacks in
case the called functions do... stuff.
- croak when encoding to ascii and an out-of-range
(non-unicode) codepoint is encountered.
0.2 Fri Mar 23 00:23:34 CET 2007
- the "could not sleep without debugging release".
it should basically work now, with many bugs as
no production tests have been run yet.
- added more testcases.
- the expected shitload of bugfixes.
- handle utf8 flag correctly in decode.
- fix segfault in decoder.
- utf8n_to_uvuni sets retlen to -1, but retlen is an
unsigned types (argh).
- fix decoding of utf-8 strings.
- improved error diagnostics.
- fix decoding of 'null'.
- fix parsing of empty array/hashes
- silence warnings when we prepare the croak message.
0.1 Thu Mar 22 22:13:43 CET 2007
- first release, very untested, basically just to claim
the namespace.
0.01 Thu Mar 22 06:08:12 CET 2007
- original version; cloned from Convert-Scalar
( run in 1.775 second using v1.01-cache-2.11-cpan-1bcd28dbaf1 )