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
18
FU.xs
18
FU.xs
|
|
@ -3,4 +3,22 @@
|
|||
#include "perl.h"
|
||||
#include "XSUB.h"
|
||||
|
||||
#include "c/common.c"
|
||||
#include "c/jsonfmt.c"
|
||||
|
||||
MODULE = FU PACKAGE = FU::XS
|
||||
|
||||
PROTOTYPES: DISABLE
|
||||
|
||||
SV *json_format(val)
|
||||
SV *val
|
||||
PREINIT:
|
||||
SV *r;
|
||||
fustr buf = {};
|
||||
CODE:
|
||||
fujson_fmt(&buf, val);
|
||||
r = fustr_sv(&buf);
|
||||
SvUTF8_on(r);
|
||||
RETVAL = r;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue