x-icon
jpeg image/jpeg
jpg image/jpeg
js application/javascript
json application/json
jxl image/jxl
mjs application/javascript
mp3 audio/mpeg
mp4
l
xsl application/xml
zip application/zip
zst application/zstd
}} }
# XML & JSON generally don't need a charset parameter
sub utf8_mimes { state $v = {map +($_,1), qw{
applic
state $v = {map +($_,1), qw{
application/atom+xml
application/javascript
application/json
application/rss+xml
application/xml
image/svg+xml
text/css
text/csv
text/
my $json = eval { fu->json({type=>'any'}) };
details_ name => 'reqbody', open => !0, sub {
summary_ 'JSON';
pre_ FU::Util::json_format($json, pr
etty => 1, canonical => 1);
} if $json;
my $formdata = eval { fu->formdata({type=>'hash'}) };
details_ name => 'reqbody', open => !0, sub {
section_ class => 'tabs', sub {
my $json = ($r->{reshdr}{'content-type'}||'') =~ /^application\/json/ && eval { FU::Util::json_parse($body, utf8 => 1) };
details_ na
for the string format yet)
=item json / jsonb
These types are converted through C<json_parse()> and C<json_format()> from
L<FU::Util>.
While C<null> is a valid JSON value, there's currently no way
SQL C<NULL>.
If you prefer to work with JSON are raw text values instead, use:
$conn->set_type(json => 'text');
That doesn't I<quite> work for the C<jsonb> type. I mean, it works, but then
there
# Error objects should be plain data structures so that they can easily
# be converted to JSON for debugging. We have to stringify $reg in the
# error object to ensure that.
+{
0;
}
sub _fmtkey($k) { $k =~ /^[a-zA-Z0-9_-]+$/ ? $k : FU::Util::json_format($k); }
sub _fmtval($v) { eval { $v = FU::Util::json_format($v) }; "$v" }
sub _inval($t,$v) { sprintf 'invalid %s: %s',
neral structure described by the schema and is
mainly useful to ensure that encoding the value as JSON will end up with the
correct data types. i.e. booleans are encoded as booleans, integers as integ
tem L<Cpanel::JSON::XS> 4.39
=item L<DBD::Pg> 3.18.0
=item L<FU> 1.2
=item L<HTML::Tiny> 1.08
=item L<JSON::PP> 4.16
=item L<JSON::SIMD> 1.06
=item L<JSON::Tiny> 0.58
=item L<JSON::XS> 4.03
=i
L::Writer> 0.900
=back
=head1 BENCHMARKS
=head2 JSON Parsing & Formatting
These benchmarks run on large-ish arrays with repeated values. JSON encoding is
sufficiently fast that Perl function cal
interesting.
Also worth noting that L<JSON::SIMD> formatting code is forked from
L<JSON::XS>, the SIMD parts are only used for parsing.
API object from L<JSON::XS> documentation.
Encode ();
use POSIX ();
use experimental 'builtin';
our @EXPORT_OK = qw/
to_bool
json_format json_parse
has_control check_control utf8_decode
uri_escape uri_unescape
query_decod
AME
FU::Util - Miscellaneous Utility Functions
=head1 SYNOPSIS
use FU::Util qw/json_format/;
my $data = json_format [1, 2, 3];
=head1 DESCRIPTION
A bunch of functions that are too small (or
rialiser> (which is used by L<JSON::XS>, L<JSON::SIMD>, L<CBOR::XS>
and others), L<JSON::PP> (also used by L<Cpanel::JSON::XS> and others),
L<JSON::Tiny> and L<Mojo::JSON>.
This function is ambiguous
mmon.c"
#include "c/compress.c"
#include "c/fcgi.c"
#include "c/fdpass.c"
#include "c/jsonfmt.c"
#include "c/jsonparse.c"
#include "c/xmlwr.c"
#include "c/libpq.h"
#include "c/pgtypes.c"
#include "c
&PL_sv_yes : &PL_sv_no;
void json_format(SV *val, ...)
CODE:
ST(0) = fujson_fmt_xs(aTHX_ ax, items, val);
void json_parse(SV *val, ...)
CODE:
ST(0) = fujson_parse_xs(aTHX_ ax, items, val