rayref is_blessed_arrayref];
use Pcore::Util::UUID qw[uuid_v1mc_str];
use Pcore::Util::Data qw[to_json];
use Pcore::Util::Hash::HashArray;
with qw[Pcore::Handle::DBI];
our $EXPORT = {
STATE
turn qq['$var'];
}
elsif ( $var->[0] == $SQL_JSON ) {
# encode and quote
$var = $self->encode_json( $var->[1] );
$var->$* =~ s/'/''/smg;
''/smg;
# quote
return qq['$var'];
}
}
sub encode_json ( $self, $var ) {
# encode
return \to_json $var;
}
sub encode_array ( $self, $var ) {
my @buf;
for my $e
D qw[uuid_v1mc_str uuid_v4_str];
use Pcore::Util::Digest qw[md5_hex];
use Pcore::Util::Data qw[to_json];
use Pcore::Util::Text qw[encode_utf8];
use Time::HiRes qw[];
# NOTE http://habrahabr.ru/post/1
=> $SQLITE_TEXT,
$SQL_FLOAT4 => $SQLITE_REAL,
$SQL_FLOAT8 => $SQLITE_REAL,
$SQL_JSON => $SQLITE_BLOB,
$SQL_INT2 => $SQLITE_INTEGER,
$SQL_INT4 => $SQLITE_INTEGER,
>[0] == $SQL_JSON ) {
$var = to_json $var->[1];
}
else {
$var = $var->[1];
}
}
else {
# transparently encode arrays to JSON
if
.
q('#include <mongocxx/instance.hpp>', '#include <bsoncxx/json.hpp>', '#include <bsoncxx/builder/stream/document.hpp>' ]; # enable MongoDB support) . "\n";
se warnings;
use 5.010_001;
use Carp;
use LWP::UserAgent;
use HTTP::Request;
use URI::Escape;
use JSON;
use Encode qw( encode_utf8 );
use Scalar::Util 'looks_like_number';
use version 0.77; our $VERSI
},
) : (),
);
$self->{ua}->default_header( 'Accept' => 'application/json' );
$self->{login_status} = "not logged in";
return $self;
}
sub do_request {
my (
my $req = HTTP::Request->new( $method => $request_url );
if ($data) {
$data = encode_json($data);
$req->content($data);
}
$self->{res} = $self->{ua}->request($req);
005;
our $VERSION = '0.02';
use Carp 'croak';
use LWP::UserAgent;
use URI;
use MIME::Base64;
use JSON;
use vars qw/$errstr/;
sub errstr { $errstr }
sub new {
my $class = shift;
my %args = @
ost($self->{url} . $url,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Content' => encode_json(\%params),
);
# print Dumper(\$res); use Data::
$errstr = "Failed to post $url: " . $res->status_line;
return;
}
return decode_json($res->decoded_content);
}
1;
__END__
=encoding utf-8
=head1 NAME
WebService::AntiCaptcha - an
w[];
use Data::MessagePack qw[];
with qw[Pcore::WebSocket::Handle];
# client attributes
has use_json => ();
has token => (); # authentication token, used on client only
has bindings => ();
const our $TX_TYPE_RPC => 'rpc';
my $CBOR = Pcore::Util::Data::get_cbor();
my $JSON = Pcore::Util::Data::get_json( utf8 => 1 );
my $MP = Data::MessagePack->new;
sub rpc_call ( $self, $method, @
xt ( $self, $data_ref ) {
my $msg = eval { $JSON->decode( $data_ref->$* ) };
# unable to decode message
return if $@;
$self->{use_json} //= 1;
$self->_on_message($msg);
ret
sub is_server_error ($self) { return substr( $_[0]->{status}, 0, 1 ) >= 5 }
# SERIALIZE
sub TO_JSON ($self) { return { $self->%* } }
sub TO_CBOR ($self) { return { $self->%* } }
1;
__END__
=pod
odule_name ~ "::Node::SystemLog" :>;
use Pcore -class, -const, -sql;
use Pcore::Util::Data qw[to_json];
with qw[<: $module_name ~ "::Node" :>];
has store_interval => 0; # PositiveOrZeroInt
has
my $row = [ #
$ev->@{qw[timestamp channel level title]},
ref $ev->{data} ? to_json $ev->{data}, readable => 1 : $ev->{data},
];
# push log record to the store buffer
i
'I18N::' => 1,
'IPC::' => 1,
'Inline::' => 1,
'JSON::' => 1,
'Lingua::' => 1,
'List::' => 1,
'Locale
e Icinga API supports.
"DATA" is optional and is a Perl data structure that will be converted to JSON.
Returns the result in a perl reference.
=item export (FULL, API_ONLY)
Returns a Perl Data str
ibutes will be included in
the export. Objects exported with FULL set to true can be converted to json and be
used for PUT requests, but not necessarily for POST requests.
"API_ONLY" is optional and
HTTP status line.
=back
=head1 DEPENDS
L<LWP::UserAgent>,
L<HTTP::Request>,
L<URI::Escape>,
L<JSON>,
L<Encode>
=head1 LICENSE
Copyright (c) 2016-, IT Services, Stockholm University
All rights r
nt-Type' => 'application/json',
],
data => defined $data ? P->data->to_json($data) : undef,
);
if ($res) {
return res $res, P->data->from_json( $res->{data} );
}
else {
return res $res, $res->{data} ? P->data->from_json( $res->{data} ) : ();
}
}
# https://api.cloudflare.com/#zone-list-zones
sub zones ( $self ) {
my $res = $self->_req( 'GET'
', \%args ) }
# path, Scalar, ArrayRef
# data, Str
# type, ArrayRef[ Enum ['css', 'html', 'js', 'json', 'perl']], list of types to process, used if path is directory
# ignore, Bool, ignore unsupporte
;
}
return;
}
# TODO, sort query params
sub canon ($self) {
...;
}
# SERIALIZE
*TO_JSON = *TO_CBOR = sub ($self) {
return $self->{uri};
};
1;
## -----SOURCE FILTER LOG BEGIN-----
#
Pcore::API::anticaptcha;
use Pcore -class, -const, -res;
use Pcore::Util::Data qw[to_b64 to_json from_json];
use Pcore::Util::Scalar qw[is_plain_scalarref];
use Pcore::API::anticaptcha::Captcha;
has
tory Server API within 5 seconds' ],
38 => [ 'ERROR_FACTORY_SERVER_BAD_JSON', 'Incorrect Factory Server JSON response, something is broken' ],
39 => [ 'ERROR_FACTORY_SERVER_ERRORI
ptcha.com/getBalance',
data => to_json { #
clientKey => $self->{api_key},
}
);
if ($res) {
my $data = from_json $res->{data}->$*;
# OK
return;
}
sub is_bool : prototype($) {
return ( is_ref $_[0] && ( UNIVERSAL::isa( $_[0], JSON::PP::Boolean:: ) || UNIVERSAL::isa( $_[0], "Data::MessagePack::Boolean" ) ) ) || ( exists $INC{'T
=> {
ENV => \%ENV,
UUID => sub { return P->uuid->str },
TO_JSON => sub { return P->data->to_json(@_) },
TO_XML => sub {
my $data = shift;
my $args = shift;
ation/x-www-form-urlencoded');
Specifying C<body> means, that we post non-form body (for example
JSON, XML or even binary data). Example:
$c->execute_oauth_request(method => "POST",
url
Pcore::Util::Scalar qw[is_path];
our $EXT_TYPE_MAP = {
perl => $DATA_TYPE_PERL,
json => $DATA_TYPE_JSON,
cbor => $DATA_TYPE_CBOR,
yaml => $DATA_TYPE_YAML,
yml => $DATA_TYPE_YAML,
th);
}
sub _clear_cache ($self) {
delete $self->@{qw[_encoded _to_uri]};
return;
}
*TO_JSON = *TO_CBOR = sub ($self) {
return $self->{path};
};
sub TO_DUMP1 ( $self, @ ) {
my $res;
ALL => [qw[encode_data decode_data]],
PERL => [qw[to_perl from_perl]],
JSON => [qw[to_json from_json]],
CBOR => [qw[to_cbor from_cbor]],
YAML => [qw[to_yaml from_yaml]],
X
=> [qw[$DATA_TYPE_PERL $DATA_TYPE_JSON $DATA_TYPE_CBOR $DATA_TYPE_YAML $DATA_TYPE_XML $DATA_TYPE_INI]],
};
const our $DATA_TYPE_PERL => 1;
const our $DATA_TYPE_JSON => 2;
const our $DATA_TYPE_CBOR =
> { #
$DATA_CIPHER_DES => 'DES',
};
our $JSON_CACHE;
# JSON is used by default
# JSON can't serialize ScalarRefs
# objects should have TO_JSON method, otherwise object will be serialized as n