jsonfmt: Add pretty option

That completes the json_format() function for now. At least, it now does
everything I had planned for it.

Ended up at a bit over 300 LOC. That's larger than I had expected, but
still alright.
This commit is contained in:
Yorhel 2025-01-30 07:52:22 +01:00
parent 1a0fb03205
commit aebe5a93dc
3 changed files with 56 additions and 8 deletions

View file

@ -51,13 +51,20 @@ The following C<%options> are supported:
=item canonical
When set to a true value, write hash keys in deterministic (sorted) order. This
option currently has no effect on tied hashes.
Boolean, write hash keys in deterministic (sorted) order. This option currently
has no effect on tied hashes.
=item pretty
Boolean, format JSON with newlines and indentation for easier reading. Beauty
is in the eye of the beholder, this option currently follows the convention
used by L<JSON::XS> and others: 3 space indent and one space around the C<:>
separating object keys and values. The exact format might change in later
versions.
=item utf8
When set to a true value, returns a UTF-8 encoded byte string instead of a Perl
Unicode string.
Boolean, returns a UTF-8 encoded byte string instead of a Perl Unicode string.
=item max_size