Changes for version 4.50 - 2026-09-08

  • Add $json->encode_to($fh, $data, [$type]) to stream encoded JSON directly to a filehandle instead of building the whole result in memory (GH #250, requested by yairlenga. designed 2016 in GH #58). Internally flushes a bounded 8k chunk buffer as it fills, keeping peak memory bounded for large data structures.
  • Encoder performance improvements suggested in GH #237 (17dec):
    • Large-integer encoding now uses a 100-digit lookup table instead of snprintf, roughly 2x faster for integers outside the existing branchless small-integer fast path (|value| > 59000).
    • encode_str now bulk-copies runs of consecutive bytes that need no escaping instead of a need()+store per byte, notably faster for strings with few or no characters to escape. Added eg/bench_large.pl with results.

Documentation

Cpanel::JSON::XS commandline utility

Modules

cPanel fork of JSON::XS, fast and correct serializing
true and false values
Type support for JSON encode