fu/FU/Util.pm
Yorhel c16a9fa493 Add initial JSON formatter
It works and can format all "plain" Perl data, but has a few known bugs
and limitations that still need to be worked out.

It's about 8x smaller than JSON::XS's encoder and *much* smaller than
Cpanel::JSON::XS, but this is just a first attempt, it'll grow.
2025-01-28 09:33:29 +01:00

17 lines
336 B
Perl

package FU::Util 0.1;
use v5.36;
use FU::XS;
use Exporter 'import';
our @EXPORT_OK = qw/json_format/;
sub json_format($val, %opt) {
my $r = FU::XS::json_format($val);
# XXX: Does this go over the bytes? If so, not setting SvUTF8_on() in the first place would be much faster.
utf8::encode($r) if $opt{utf8};
$r
}
1;