ur code may still require each of them to
serialize themselves as JSON even though neither class naturally has anything
to do with JSON (for example, C<Person> and C<Order> classes). There are a
numb
= shift;
$self->_request(
method => 'post',
'Content-Type' => 'application/json',
Accept => 'application/json',
@_
);
}
sub get {
my $self = shift;
$self->_request(
method => 'get',
'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8',
Accept => 'application/json',
@_
);
}
sub _request {
my ($self, %args) = @_;
$self->request_cb(\%args) if $self->can('requ
lsif ($res->content_type eq 'application/json') {
my $response = $self->graft('response', $res->decoded_content);
return $self->_return_error('Invalid JSON content returned', $res) if !$response;
ntext *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL v
_USE_JSON_BUILTIN
#define DUK_USE_JSON_DECNUMBER_FASTPATH
#define DUK_USE_JSON_DECSTRING_FASTPATH
#define DUK_USE_JSON_DEC_RECLIMIT 1000
#define DUK_USE_JSON_EATWHITE_FASTPATH
#define DUK_USE_JSON_ENC
_RECLIMIT 1000
#define DUK_USE_JSON_QUOTESTRING_FASTPATH
#undef DUK_USE_JSON_STRINGIFY_FASTPATH
#define DUK_USE_JSON_SUPPORT
#define DUK_USE_JX
#define DUK_USE_LEXER_SLIDING_WINDOW
#undef DUK_USE_LIGH
define DUK_USE_NONSTD_FUNC_STMT
#define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT
#define DUK_USE_NONSTD_JSON_ESC_U2028_U2029
#define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT
#define DUK_USE_NONSTD_STRING_FROMCHAR
package JavaScript::Duktape::XS;
use strict;
use warnings;
use parent 'Exporter';
use JSON::PP; # required to properly handle booleans
use XSLoader;
our $VERSION = '0.000081';
XSLoader::load( __PAC
they will be
handled correctly.
Plain scalars are converted thus:
=over
=item * Instances of L<JSON::PP::Boolean> become JavaScript booleans.
=item * Strings are interpreted as character strings.
my $c = shift->openapi->valid_input or return;
my $track = $c->req->json;
return add_with_json($c, $track, "tracks", $c->openapi->spec('/components/schemas/Track/properties'));
or return;
my $track = $c->req->json;
my $trackId = $c->param('trackId');
$track->{id} = $trackId;
return update_with_json($c, $track, "tracks", $c->openapi->spec('
:utils::log_filter;
use PDL;
use PDL::NiceSlice;
use PDL::Finance::TA;
use POSIX ();
use JSON::XS qw(encode_json);
$PDL::doubleformat = "%0.6lf";
has debug => 0;
has plot_engine => 'highcharts';
has
$xypdlclean);
push @plotinfo, {
title => $o->[0],
data => encode_json $xypdlclean->unpdl,
impulses => (ref $o->[2] eq 'HASH' and $o->[2]->{with} eq 'impuls
$xypdlclean);
push @plotinfo, {
title => $o->[0],
data => encode_json $xypdlclean->unpdl,
impulses => 1,
id => $o->[3],
};
}
re
nanceta::data;
use Scalar::Util qw(blessed);
use Browser::Open ();
use YAML::Any ();
use JSON::XS qw(encode_json);
use Template;
$PDL::doubleformat = "%0.6lf";
$| = 1;
has debug => 0;
has timezone =>
_$type.html");
## highcharts requires timestamp in milliseconds
## transpose the data for JSON charting
my $chart_type_pretty;
my @charts = ();
$type //= 'OHLC';
my $next_y_axi
chart_type_pretty = ($type eq 'CANDLE') ? 'Candlestick' : 'OHLC Price';
my $ppdl = encode_json pdl($data(,(0)) * 1000, $data(,(1)), $data(,(2)), $data(,(3)), $data(,(4)))->transpose->unpdl;
Glitch;
use 5.006; use strict; use warnings;
our $VERSION = '0.04';
use Glitch;
use YAML::XS;
use JSON;
use base 'Terse::Plugin';
sub build_plugin {
my ($self) = @_;
$self->build_glitch_config if $
ig_parser} = sub { YAML::XS::Load($_[0]) };
} elsif ($self->{format} eq 'JSON') {
$self->{glitch_config_parser} = sub { JSON->new->encode($_[0]) };
}
Glitch::build_meta(
map {($_, $self->{$_})}
(json => $rv);
}
sub index { }
1;
__DATA__
@@ schedule/index.html.ep
% layout 'admin'
<h1>Schedule management</h1>
<p>Possitble actions:</p>
<dl><dt>GET /admin/schedule/list</dt>
<dd>Creates a JSON
he talk with the given ID</dd>
<dt>PUT /admin/schedule/talk/</dt>
<dd>Create a new talk (requires JSON object)</dd>
<dt>PUT /admin/schedule/talk/:id</dt>
<dd>Update the data of the talk with the given
talk->video_fragments);
$data->{filename} = $talk->relative_name . "/main" . $c->srconfig->get("preview_exten");
$data->{room} = $talk->room;
$c->render(json => $data);
}
1;
use SReview::API::Helpers qw/db_query update_with_json add_with_json is_authed/;
use Mojo::Util 'slugify';
use Mojo::JSON qw/encode_json decode_json/;
use DateTime::Format::Pg;
use SReview::Talk;
s
g->parse_datetime($talk->{endtime})->iso8601();
if($talk->{flags}) {
$talk->{flags} = decode_json($talk->{flags});
}
if(!is_authed($c)) {
delete($talk->{
return $talks;
}
sub fixup {
my $talk = shift;
if($talk->{flags}) {
$talk->{flags} = decode_json($talk->{flags});
}
return $talk;
}
sub listByEvent {
my $c = shift->openapi->valid_input or r
package WebService::Chroma::UA;
use Moo;
use LWP::UserAgent;
use JSON;
use Module::Load;
has base_url => (
is => 'ro',
);
has embeddings_model => (
is => 'rw',
trigger => sub {
if ($_[1] && $_
s ua => (
is => 'ro',
default => sub {
LWP::UserAgent->new();
}
);
has json => (
is => 'ro',
default => sub {
JSON->new;
}
);
sub get {
shift->request(
type => 'GET',
@_
);
}
sub po
} else {
$res = $self->ua->post(
$url,
content => $self->json->encode($params{data}),
'Content-Type' => 'application/json'
);
}
return $self->response($res);
}
sub response {
my ($s
-MCPAN -e install 'File::Globstar'
From source:
$ perl Build.PL
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'File-Globstar' version '0.1'
$ ./Build
$ ./Build install
Fro
ers;
sub add {
my $c = shift->openapi->valid_input or return;
my $user = $c->req->json;
return add_with_json($c, $user, "users", $c->openapi->spec('/components/schemas/User/properties'));
}
sub
put or return;
my $userId = $c->param("userId");
my $user = $c->req->json;
$user->{id} = $userId;
return update_with_json($c, $user, "users", $c->openapi->spec('/components/schemas/User/propert
ession->{room} = $row->[4];
my $json = {};
if(!$c->session->{volunteer}) {
my $apikey = random_string();
$json->{apiKey} = $apikey;
$c
i->valid_input or return;
my $speaker = $c->req->json;
$c->app->log->debug(join(',', keys %$speaker));
return add_with_json($c, $speaker, "speakers", $c->openapi->spec('/components/
rId = $c->param("speakerId");
my $speaker = $c->req->json;
$speaker->{id} = $speakerId;
return update_with_json($c, $speaker, "speakers", $c->openapi->spec('/components/sche
:UserAgent;
use JSON;
has ua => (
is => 'ro',
default => sub {
LWP::UserAgent->new();
}
);
has json => (
is => 'ro',
default => sub {
JSON->new;
}
);
ha
ua->post(
$url,
content => $self->json->encode({
model => $self->model,
prompt => $data
})
);
if ($res->is_success) {
my $embedding = $self->json->decode($res->decoded_content)->{embe
se 5.006; use strict; use warnings;
our $VERSION = '0.02';
use base 'Terse::Plugin';
use CHI; use JSON;
sub build_plugin {
my ($self) = @_;
$self->cache = CHI->new(
driver => 'Memory',
global =
Wheel::SocketFactory
Wheel::ReadWrite
Filter::Stackable
Filter::Line
Filter::JSONMaybeXS
);
use Try::Tiny;
# Version of this software
our $VERSION = '0.010';
# create a new bles
reate a stackable filter so we can talk in json
my $filter = POE::Filter::Stackable->new();
$filter->push( POE::Filter::Line->new(), POE::Filter::JSONMaybeXS->new(), );
# Create a rw_whee
reate a stackable filter so we can talk in json
my $filter = POE::Filter::Stackable->new();
$filter->push( POE::Filter::Line->new(), POE::Filter::JSONMaybeXS->new(), );
# Create a rw_whee
) = @_;
if (!$self->config_file) {
my $file = $0;
($self->config_file = $0) =~ s/(\.psgi)?$/.json/;
}
$self->data = $self->_read_file($self->config_file);
return $self;
}
sub find {
my ($sel
@_;
return $self->graft('data', $content);
}
1;
__END__
=head1 NAME
Terse::Plugin::Config - JSON configs
=head1 VERSION
Version 0.04
=cut
=head1 SYNOPSIS
package MyApp::Plugin::Config;
u