fu/FU.xs
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

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