}
sub _is_text {
my ($content_type) = @_;
return $content_type =~ /(\bx(?:ht)?ml\b|text|json|javascript)/;
}
# Fancy banner to print on startup
sub print_banner {
if (setting('startup_i
ess;
$Log::Progress::VERSION = '0.13';
use Moo 2;
use Carp;
use IO::Handle; # for 'autoflush'
use JSON;
# ABSTRACT: Conveniently write progress messages to logger or file handle
has to => (
my ($self, $data)= @_;
ref $data eq 'HASH' or croak "data must be a hashref";
$self->_writer->(JSON->new->ascii->encode($data));
}
sub substep {
my ($self, $step_id, $step_contribution, $title)=
ress-associated data, use this method.
The data must be a hashref. It gets encoded as pure-ascii JSON.
=head2 substep
$progress_obj= $progress->substep( $id, $contribution, $title );
Create a na
h $value;
# XXX: This is insufficiently precise. It's here to keep us from believing
# that JSON::XS::Boolean objects, which end up looking like 0 or 1, are
# integers. -- rjbs, 2008-07-24
$
=~ m!\Ahttps?:/(/?)!i) {
my $is_unix = !$1;
my $ht;
require JSON;
state $json = JSON->new->allow_nonref;
if ($is_unix) {
require HTTP::Tiny::UNIX;
n},
"x-riap-action" => $action,
"x-riap-fmt" => "json",
"content-type" => "application/json",
);
my $args = $extra->{args} // {};
for (keys
$ht->post(
$url, {
headers => \%headers,
content => $json->encode($args),
});
return [500, "Network error: $htres->{status} - $htres->{
package Log::Progress::Parser;
$Log::Progress::Parser::VERSION = '0.13';
use Moo 2;
use JSON;
# ABSTRACT: Parse progress data from a file
has input => ( is => 'rw' );
has input_pos => ( is => '
tle;
$state->{contribution}= $contribution+0;
}
elsif ($remainder =~ /^\{/) {
my $data= JSON->new->decode($remainder);
$state->{data}= !defined $self->on_data? $data
: $self->on_data-
#
step => { $step_id => \%step_state, ... },
data => \%data, # most recent JSON data payload, decoded
}
Substeps may additionally have the keys:
idx => $order_o
',
req => 1,
pos => 0,
},
},
'cmdline.default_format' => 'json-pretty',
};
sub parse_csel {
require Data::CSel;
my %args = @_;
[200, "OK", Data::CSe
at L<https://github.com/perlancar/perl-App-CSelUtils>.
=head1 SEE ALSO
L<htmlsel>, L<orgsel>, L<jsonsel>, L<yamlsel>, L<podsel>, L<ppisel>
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 CONT
#pod if you prefer!)
#pod
#pod =item *
#pod
#pod Rx's type C<//bool> is deliberately targeted at JSON like boolean objects, so
#pod we'll also accept undef and 1 as "truthy" values.
#pod
#pod =back
#
definition of a schema,
if you prefer!)
=item *
Rx's type C<//bool> is deliberately targeted at JSON like boolean objects, so
we'll also accept undef and 1 as "truthy" values.
=back
As we are expe
});
}
return 1 unless ref $value and ! (
eval { $value->isa('JSON::XS::Boolean') }
or
eval { $value->isa('JSON::PP::Boolean') }
or
eval { $value->isa('boolean') }
);
$s
od },
#pod };
#pod
#pod my $schema = $rx->make_schema($success);
#pod
#pod my $reply = $json->decode( $agent->get($http_request) );
#pod
#pod die "invalid reply" unless $schema->check($rep
ents => '//str',
},
},
};
my $schema = $rx->make_schema($success);
my $reply = $json->decode( $agent->get($http_request) );
die "invalid reply" unless $schema->check($reply);
=he
});
}
# XXX: This is insufficiently precise. It's here to keep us from believing
# that JSON::XS::Boolean objects, which end up looking like 0 or 1, are
# integers. -- rjbs, 2008-07-24
i
",
value => $value,
});
}
# XXX: Really, we need a way to know whether (say) the JSON was one of the
# following: { "foo": 1 } or { "foo": "1" }
# Only one of those is providing
fined($value)
and ref($value)
and (
eval { $value->isa('JSON::XS::Boolean') }
or
eval { $value->isa('JSON::PP::Boolean') }
or
eval { $value->isa('boolean') }
020", "List::BinarySearch"],
'FP::RegexMatch' => ["5.020"],
'FP::JSON' => ['JSON', "5.020"],
'FP::Abstract::Sequence::t' => ['FP::autobox'],
'Chj::Serialize
b quote_javascript {
@_ == 1 or fp_croak_arity 1;
my ($str) = @_;
#require JSON::MaybeXS;
#JSON->new->allow_nonref(1)->encode($str)
# this doesn't turn special characters into ba
just use
# JSON::PP directly and suck up the terrible performance
require JSON::PP;
JSON::PP->new->allow_nonref(1)->encode($str)
# <mst> note that JSON::MaybeXS is trivial
o_match_vars);
use File::Basename;
use File::Path;
use File::Spec;
use List::Util;
use Mojo::JSON qw/to_json/;
use Mojo::Transaction::HTTP;
use Mojo::URL;
use Mojo::Log;
use Mojo::Base 'Mojo::UserAgen
FOUND => 404;
our $VERSION = '1.25';
# TODO: Timeout, fallback
# TODO: Expected result content (json etc)
# MOJO_USERAGENT_CONFIG
## no critic (ProhibitMagicNumbers)
has 'connect_timeout' => sub
my ($self, $url, @opts) = @_;
my $key = join q{,}, $self->sort_query($url), (@opts ? to_json(@opts > 1 ? \@opts : $opts[0]) : ());
return $key;
}
sub is_considered_error {
my ($sel
ields { return $fields; }
BEGIN { $fields = {
"format" => new WWW::Shopify::Field::String("(xml|json)"),
"address" => new WWW::Shopify::Field::String::URL(),
"topic" => new WWW::Shopify::Field::St
it/Bundle-DadaMail>
=head1 CONTENTS
Bundle::DadaMail::IncludedInDistribution
DBI
DBD::SQLite
JSON - actually required for Dada Mail - Pure Perl version included, but you probably want to use a fa
/bin/perl
use strict;
use warnings;
package WWW::Shopify::URLHandler;
use JSON qw(from_json to_json encode_json decode_json);
use Data::Dumper;
use Scalar::Util qw(weaken);
use DateTime;
use Encode;
0]->{_parent}; }
sub get_url {
my ($self, $url, $parameters, $type) = @_;
$type = "application/json" unless $type;
my $uri = URI->new($url);
my %filtered = ();
if ($parameters->{fields} && ref($
ls($1);
$self->parent->max_api_calls($2);
}
my $content = $response->decoded_content;
# From JSON because decodec content is already a perl internal string.
# Sigh. No. It's not. As per https://
package WWW::Shopify::GraphQL;
use strict;
use warnings;
use JSON qw(from_json decode_json encode_json);
use Encode;
use Scalar::Util qw(blessed);
use Data::Dumper;
sub new {
my ($package, $sa) =
ternal_query {
my ($self, $hash, $json) = @_;
my $request = HTTP::Request->new(POST => $self->sa->encode_url('/admin/api/' . $self->sa->api_version . '/graphql.json'));
my $content = ref($hash) ? e
ncode_json({ "query" => $content, "variables" => ($json || {}) });
$request->content($body);
$request->header('Content-Length' => length($body));
$request->header('Accept' => 'application/json');
ing and manipulating.
=item JSON-Like Hash: The item is similar to the WWW::Shopify::Model, but lacks all-non canonical shopify references, and is ready to be encode_json'd before being sent off to S
ts have to be accessed through their parent objects /product/3242134/variants/342342.json vs. /variants/342342.json
These tell you which objects have to go through their parent, and which don't. It t
e($metafield);
}
=head2 from_json($package, $json_hash, [$associated])
Returns a WWW::Shopify::Model::... intermediate object from a hash that's been decoded from a JSON object (i.e. normal shopify
_int($_[1]); }
package WWW::Shopify::Field::Boolean;
use Scalar::Util qw(looks_like_number);
use JSON;
use parent 'WWW::Shopify::Field';
sub sql_type { return "bool"; }
sub generate { return (rand()
sub data_type { return WWW::Shopify::Field::TYPE_BOOLEAN; }
sub to_shopify { return $_[1] ? JSON::true : JSON::false; }
sub from_shopify { return $_[1] ? 1 : 0; }
package WWW::Shopify::Field::Float;
n WWW::Shopify::Field::TYPE_QUANTITATIVE; }
# Freeform datastructure. Meaning we convert it to a JSON hash, but we don't do any further processing at all.
package WWW::Shopify::Field::Freeform;
use p