jsonfmt: Add max_size and max_depth options

This commit is contained in:
Yorhel 2025-01-29 15:05:48 +01:00
parent a85ff98914
commit 163a60b4ba
4 changed files with 101 additions and 59 deletions

View file

@ -45,6 +45,25 @@ be sufficient. The following is probably an improvement:
json_format($data) =~ s{</}{<\\/}rg =~ s/<!--/<\\u0021--/rg;
The following C<%options> are supported:
=over
=item utf8
When set to a true value, returns a UTF-8 encoded byte string instead of a Perl
Unicode string.
=item max_size
Maximum permitted size, in bytes, of the generated JSON string. Defaults to 1 GiB.
=item max_depth
Maximum permitted nesting depth of Perl values. Defaults to 512.
=back
=back
(Why the hell yet another JSON codec when CPAN is already full of them!? Well,