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.
This commit is contained in:
parent
9c80f2465a
commit
c16a9fa493
10 changed files with 421 additions and 0 deletions
17
FU/Util.pm
Normal file
17
FU/Util.pm
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue