package Mojo::SQLite::Results;
use Mojo::Base -base;
use Mojo::Collection;
use Mojo::JSON 'from_json';
use Mojo::Util 'tablify';
our $VERSION = '3.009';
has [qw(db sth)];
sub new {
my $self = sh
my @json_names = keys %{$self->{expand}{json}};
for my $r (@rows) { $r->{$_} = from_json $r->{$_} for grep { $r->{$_} } @json_names }
} else {
my $cols = $self->columns;
my @json_idxs
= grep { $self->{expand}{json}{$cols->[$_]} } 0..$#$cols;
for my $r (@rows) { $r->[$_] = from_json $r->[$_] for grep { $r->[$_] } @json_idxs }
}
return @rows;
}
1;
=head1 NAME
Mojo::SQLi
(<<'EOF');
type Query {
helloWorld: String
}
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ helloWorld => 'Hello world!' }
Types::Standard -all;
use JSON::MaybeXS;
with qw(GraphQL::Role::FieldDeprecation);
our $VERSION = '0.02';
use constant DEBUG => $ENV{GRAPHQL_DEBUG};
my $JSON_noutf8 = JSON::MaybeXS->new->utf8(0)->al
(', ', @argtuples).')' if @argtuples;
$line .= ': ' . $type->to_string;
$line .= ' = ' . $JSON_noutf8->encode(
$type->perl_to_graphql($field->{default_value})
) if exists $field->{de
my @directives = map {
my $args = $_->{arguments};
my @argtuples = map { "$_: " . $JSON_noutf8->encode($args->{$_}) } keys %$args;
'@' . $_->{name} . (@argtuples ? '(' . join(', '
woff2
application/java-archive jar war ear
application/json json
application/mac-binhex40 hqx
application/msword
w of others, please drop me a message.
_
entries => [
{
summary => 'Sort JSON objects by key field(s)',
module => 'App::PipeFilter',
script => 'jsort',
se drop me a message.
=head1 ACME::CPANMODULES ENTRIES
=over
=item * L<App::PipeFilter> - Sort JSON objects by key field(s)
Author: L<RCAPUTO|https://metacpan.org/author/RCAPUTO>
Script: L<jsort>
Moo::Role;
use GraphQL::MaybeTypeCheck;
use Types::Standard -all;
use JSON::MaybeXS;
our $VERSION = '0.02';
my $JSON_noutf8 = JSON::MaybeXS->new->utf8(0)->allow_nonref;
=head1 NAME
GraphQL::Role::F
return $line if !$value->{is_deprecated};
$line .= ' @deprecated';
$line .= '(reason: ' . $JSON_noutf8->encode($value->{deprecation_reason}) . ')'
if $value->{deprecation_reason} ne
$
doc(<<'EOF');
type Query { dateTimeNow: DateTime }
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ dateTimeNow => sub { DateTime-
tOptionsFromArray);
use GraphQL::Client;
use JSON::MaybeXS;
use Text::ParseWords;
use namespace::clean;
our $VERSION = '0.605'; # VERSION
my $JSON = JSON::MaybeXS->new(canonical => 1);
sub _croak {
s->{filter}) {
eval { require JSON::Path::Evaluator } or die "Missing dependency: JSON::Path\n";
my @values = JSON::Path::Evaluator::evaluate_jsonpath($data, $filter);
if (@val
code('UTF-8', $_) } @args if grep { /\P{ASCII}/ } @args;
my %options = (
format => 'json:pretty',
unpack => 0,
);
GetOptionsFromArray(\@args,
'version'
doc(<<'EOF');
type Query { dateTimeNow: DateTime }
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ dateTimeNow => sub { DateTime-
'names', {name => 'Daniel'})->last_insert_id;
# JSON roundtrip
say $db->query('select ? as foo', {json => {bar => 'baz'}})
->expand(json => 'foo')->hash->{foo}{bar};
# Select one row at
te->new('sqlite:test.db') };
get '/' => sub ($c) {
my $db = $c->sqlite->db;
$c->render(json => $db->query(q{select datetime('now','localtime') as now})->hash);
};
app->start;
In this
additional features to the L<SQL::Abstract>
query methods in L<Mojo::SQLite::Database> such as C<-json> and
C<limit>/C<offset>. The C<for> feature is not applicable to SQLite queries.
$sql->db->sel
%$request};
if ($method eq 'GET' || $method eq 'HEAD') {
$data->{variables} = $self->json->encode($data->{variables}) if $data->{variables};
my $params = www_form_urlencode($data
{sep}${params}#/ or $url .= "${sep}${params}";
}
else {
my $encoded_data = $self->json->encode($data);
$options->{content} = $encoded_data;
$options->{headers}{'content
sub _handle_error {
my $self = shift;
my ($resp) = @_;
my $data = eval { $self->json->decode($resp->{content}) };
my $content = $resp->{content} // 'No content';
my $reason
e 'Pegex::Receiver';
use Types::Standard -all;
use GraphQL::MaybeTypeCheck;
use JSON::MaybeXS;
use Carp;
my $JSON = JSON::MaybeXS->new->allow_nonref->canonical;
my @KINDHASH = qw(
scalar
union
_boolean (Any $param = undef) {
return unless defined $param;
return $param eq 'true' ? JSON->true : JSON->false;
}
method got_null (Any $param = undef) {
return unless defined $param;
return
Perl representation and the "GraphQL
representation". A "GraphQL representation" means something
JSON-encodeable: an "object" (in Perl terms, a hash), an array (Perl:
array-reference), string, number
n> be JSON-encoded, not things that I<have been> so encoded: this
means, among other things, do not surround strings in C<">, and for
boolean values, use the mechanism in L<JSON::MaybeXS>: C<JSON->tru
use v5.28;
use warnings;
use FindBin;
use lib $FindBin::Bin. "/../lib";
use JSON;
use File::Slurp qw(read_file);
use Encode qw(encode);
use Getopt::Long qw< GetOptions >;
use Mojo::DOM;
use NewsExtr
;
use NewsExtractor::GenericExtractor;
my %opts;
GetOptions(
\%opts,
"file=s",
);
my $json = JSON->new->pretty->canonical->utf8->allow_blessed->convert_blessed;
if ($opts{file}) {
my $ht
jo::DOM->new($html);
my $x = NewsExtractor::GenericExtractor->new( dom => $dom );
print $json->encode({
file => $opts{file},
extracted => {
site_name => $x->site_n
sExtractor::JSONLDExtractor;
use Moo;
extends 'NewsExtractor::TXExtractor';
use Mojo::Transaction::HTTP;
use Types::Standard qw( InstanceOf HashRef ArrayRef );
use Mojo::JSON qw(from_json);
use Impor
my ($self) = @_;
my $el = $self->dom->at('script[type="application/ld+json"]') or return {};
my $x = from_json( $el->text );
if (HashRef->check($x)) {
return $x;
}
if (
package Image::Randim::Source::Unsplash;
our $VERSION = '0.01';
use v5.20;
use warnings;
use JSON;
use Moose;
has 'name' => ( is => 'ro',
isa => 'Str',
default => 'Unsplash',
);
has 'api_url
return $self->api_url.$self->api_key;
}
sub get_image {
my $self = shift;
my $data = JSON->new->decode($self->get_response);
my $image = Image::Randim::Image->new(
url => $$d
with 'Image::Randim::Source::Role';
sub get_image {
my $self = shift;
my $data = JSON->new->decode($self->get_response);
$data = $$data{'response'};
my $image = Image::Ra
on the provider's site to get the random image's
data.
This is typically a API call that returns JSON.
=head2 C<get_image>
Plugins must return an Image::Randim::Image object, which is populated
wit
In the SYNOPSIS example, you see that JSON is returned from the
get_response() call to the provider's API (which uses the provided
url()) -- and then that JSON is parsed into a hash that is used to
w( HashRefRestricted Boolean );
use Type::Utils -all;
use Types::Standard -types;
use Carp;
use JSON::PP;
use Scalar::Util qw(blessed);
our $VERSION = '1.0.2'; # VERSION
my $meta = __PACKAGE__->me
stanceOf['JSON::PP::Boolean'],
constraint_generator => sub {
return $meta->get_type('Boolean') if !@_;
return sub {
return if ! ( blessed $_ and $_->isa('JSON::PP::Boo
ion;
},
);
coerce Boolean,
from Bool,
via {
my $new = $_ ? $JSON::PP::true : $JSON::PP::false;
$new;
}
;
__PACKAGE__->meta->make_immutable;
1;
__END
);
has json_rpc => ( is => 'ro', isa => Str, default => sub { '2.0' } );
state $request_id = 1;
sub _request ( $self, $method, $params = {}, $opts = {} ) {
my $rpc_data = {
jsonrpc => $
lt;
$api->_set_token( $token );
}
my %header = ( 'Content-Type' => 'application/json' );
$header{'HPLS-AUTH'} = $api->token if $api->token;
my $uri = join '/',
$api-
eader,
json => $rpc_data,
);
my $response = $tx->res;
if ( $tx->error ) {
carp $tx->error->{message};
return;
}
my $data = $response->json;
if ( $da
use Mojolicious::Lite; # "strict", "warnings", "utf8" and Perl 5.10 features
use JSON::Schema::ToJSON;
use Mojo::JSON;
my $spec_uri = shift || die "Need a spec URI: $0 <spec_uri> <base_path> [<ex
a = $spec->{'responses'}{$response}{schema};
$data = JSON::Schema::ToJSON->new(
example_key => 'x-example',
)->json_schema_to_json( schema => $schema );
$c->stash( status => $response
);
}
}
$data->{messages} = delete $data->{errors} if $data->{errors};
return Mojo::JSON::encode_json( $data );
},
};
app->start;