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.
24 lines
373 B
Text
24 lines
373 B
Text
#define PERL_NO_GET_CONTEXT
|
|
#include "EXTERN.h"
|
|
#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
|