warnings;
our $VERSION = '1.20180106'; # VERSION
use Carp;
use IO::Handle;
use IO::Select;
use JSON;
use English qw( -no_match_vars );
my $DEBUG = 0;
sub new {
my ( $Class, $Args ) = @_;
my $Data = eval { decode_json($Value) };
return $Data;
}
sub Send {
my ( $Self, $fh, $Value ) = @_;
$Value->{'pid'} = $PID;
my $Encoded = encode_json($Value);
print $fh "$En
d
IPC Send.
=back
=head1 JSON
Note: All communication between the parent and a child are serialised using JSON.pm, please
be aware of the data type restrictions of JSON serialisation.
=head1 DEPE
::AuthStorage::ConfigJSON;
$Moo::Google::AuthStorage::ConfigJSON::VERSION = '0.03';
# ABSTRACT: Specific methods to fetch tokens from JSON data sources
use Moo;
use Config::JSON;
has 'pathToTokensF
ile' => ( is => 'rw', default => 'config.json' )
; # default is config.json
# has 'tokensfile'; # Config::JSON object pointer
my $tokensfile;
has 'debug' => ( is => 'rw', default => 0 );
sub s
etup {
my $self = shift;
$tokensfile = Config::JSON->new( $self->pathToTokensFile );
}
sub get_credentials_for_refresh {
my ( $self, $user ) = @_;
return {
client_id => $s
elay->begin);
},
sub {
my ($delay, $res, $tx) = @_;
return $c->render(json => $res) if $res;
return $c->render_exception;
},
);
}
=head1 ATTRIBUTES
=h
return template 'main';
};
# fetch graph code
get '/graph_data' => sub {
return to_json $api->graph_data;
};
post '/login' => sub {
my $user = params->{username};
m
gged_in_user' || request->address eq '127.0.0.1'){
return to_json { status => 1 };
}
return to_json {status => 0};
};
get '/time' => sub {
my ($y, $m, $d, $h,
' => sub {
my $log = $log->child('/light');
$log->_6("/light");
return to_json $api->_config_light;
};
get '/get_config/:want' => sub {
my $want = params->{want};
package PEF::Front::Ajax;
use strict;
use warnings;
use Encode;
use JSON;
use URI::Escape;
use Template::Alloy;
use Data::Dumper;
use Scalar::Util qw(blessed);
use PEF::Front::Config;
use PEF::Front:
EF::Front::Validator;
use PEF::Front::NLS;
use PEF::Front::Response;
my $json_utf8_object;
BEGIN {
$json_utf8_object = JSON->new->utf8->convert_blessed;
}
sub ajax {
my ($request, $context) = @_;
ext_post_hook($context);
}
my $vreq = eval {validate(\%request, $context)};
my $response;
my $json = $src eq 'ajax';
$src = 'submit' if $src eq 'get';
my $new_loc;
if (!$@) {
my $as = get_me
's also special parameter B<json> that has to be encoded JSON value.
When it's present, then parameters are overwritten from this decoded JSON.
Request parsing detects JSON or XML content-types and c
ML
---
params:
select@:
Another way to submit array or hash is to use C<json> form data field or
to post JSON or XML content.
Array of files has type 'array'.
=item Maximum or minimum size
header.
=item B<answer_data>
Replaces answer hash with C<answer_data> field before encoding to JSON.
It can be only B<ARRAY> or B<HASH> reference.
=item B<answer_http_response>
Uses supplied HTT
i::EnvUI::Event;
use Carp qw(confess);
use Crypt::SaltedHash;
use Data::Dumper;
use DateTime;
use JSON::XS;
use Logging::Simple;
use Mock::Sub no_warnings => 1;
use RPi::Const qw(:all);
our $VERSION
$_[0]->{config_file} = $_[1] if defined $_[1];
return $_[0]->{config_file} || 'config/envui.json';
}
sub db {
my ($self, $db) = @_;
$self->{db} = $db if defined $db;
return $self->{d
lf->testing(1);
$self->db(App::RPi::EnvUI::DB->new(testing => 1));
$self->config('t/envui.json');
$self->_parse_config;
if ($self->test_mock) {
my $mock = Mock::Sub->new;
f) = @_;
my $req = GET 'https://login.yandex.ru/info';
$req->uri->query_form(
format => 'json',
oauth_token => $self->{session}->data->{oauth_access_token}{$self->{service}}
);
$req;
}
s
cookie>.
See C<cfg_parse_extra_params> in L<PEF::Front::Config>.
=item B</ajax$Method>
Returns JSON answer, doesn't support redirects. By default doesn't parse
parameters from URI path. Method name
type('application/json');
$req->header(Authorization => 'Bearer ' . $self->{session}->data->{oauth_access_token}{$self->{service}});
$req->header(Accept => 'application/json');
$req;
}
sub
nt::Oauth;
use strict;
use warnings;
use URI;
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON;
use PEF::Front::Config;
use PEF::Front::Session;
my $coro_ae_lwp;
BEGIN {
if ($INC{'Coro/AnyE
ri {0}
sub _required_state {1}
sub _returns_state {1}
sub _decode_token {
decode_json($_[1]);
}
sub user_info_scope {
my ($self) = @_;
cfg_oauth_scopes($self->{service})->{user_inf
_get_user_info_request);
if ($response && $response->decoded_content) {
$info = eval {decode_json $response->decoded_content};
$exception = $@;
} else {
$exception = "timeout";
}
} els
use strict;
use warnings;
use PEF::Front::Config;
use PEF::Front::Connector;
use Geo::IPfree;
use JSON;
use Storable;
use MLDBM::Sync;
use MLDBM qw(MLDBM::Sync::SDBM_File Storable);
use Fcntl qw(:DEFA
sage_json;
if (cfg_no_nls) {
$message_json = to_json([$msgid]);
} else {
db_connect->run(
sub {
($message_json, $id_nls_msgid) = $_->selectrow_array(
q{
select message_json, id
= ?) and short = ?
},
undef, $msgid, $msgid, $lang
);
if (not defined $message_json) {
$found = 0;
($id_nls_msgid) = $_->selectrow_array(
q{
select id_nls_msg
bbix-sender.
$Zabbix::Sender::VERSION = '0.07';
use Moo;
use namespace::autoclean;
use Carp;
use JSON;
use IO::Socket;
use IO::Select;
use Net::Domain;
use Types::Standard -types;
has 'server' => (
=> Bool,
'default' => 0,
);
has '_json' => (
'is' => 'rw',
'isa' => InstanceOf['JSON'],
'lazy' => 1,
'builder' => '_init_json',
);
has '_last_sent' => (
'is'
,
'isa' => Bool,
'default' => 0,
);
sub _init_json {
my $self = shift;
my $JSON = JSON::->new->utf8();
return $JSON;
}
sub _init_hostname {
my $self = shift;
retu
n (OAuth) interface.
=cut
package EveOnline::SSO;
use 5.008001;
use utf8;
use Modern::Perl;
use JSON::XS;
use URI::Escape;
use MIME::Base64;
use URI::URL;
use LWP::UserAgent;
use LWP::Socket;
use
, %params ) = @_;
return unless $params{code} || $params{refresh_token};
return JSON::XS::decode_json( $self->demo ) if $self->demo;
my $base64 = encode_base64($self->client_id.':'.$sel
rant_type => $params{code} ? 'authorization_code' : 'refresh_token',
});
return JSON::XS::decode_json( $res->content );
}
=over
=item B<get_token_through_webserver()>
Return hashref with
nt;
use 5.008001;
use utf8;
use Modern::Perl;
use LWP::UserAgent;
use Storable qw/ dclone /;
use JSON::XS;
use Moo;
has 'ua' => (
is => 'ro',
default => sub {
my $ua = LWP::UserAgent
uery string hash ref. Can be empty
},
[ {}, [] ] # Body structure. Converting to json. Optional
);
$client->post(['universe', 'names'], {}, [90922771,188956223]);
=cut
state $json = JSON::XS->new->utf8;
$body = $json->encode( $params );
$request->content( $body );
}
$request->header( 'content-type' => 'application/json; charset=UTF
#!/usr/bin/perl
use DBIx::Connector;
use Encode;
use JSON;
use Data::Dumper;
my $dbuser = ((getpwuid $>)[0]);
my $dbname = $dbuser;
my $dbpass = "";
my $conn;
my $fname;
my $lang;
for (my $i = 0; $i
t, msgid, message_json
from nls_msgid join nls_message using (id_nls_msgid)
where short = ?
union
select coalesce(context, '') context, msgid_plural, message_json
from nls_m
}
);
my %ctx;
for my $row (@$messages) {
my $decoded_msg = from_json($row->{message_json});
my $message = $row->{message_json};
if (ref $decoded_msg eq 'ARRAY' && @$decoded_msg == 1) {
subs
package PEF::Front::Request;
use strict;
use warnings;
use JSON;
use Carp ();
use utf8;
use Encode;
use PEF::Front::Headers;
use PEF::Front::File;
use PEF::Front::Config;
use XML::Simple;
use URI;
my
ms} || {};
$self->{params} = {%$p, %$q};
if (exists $self->{params}{json}) {
my $form = eval {from_json $self->{params}{json}} || {};
$self->logger({level => "warn", message => $@}) if $@;
$s
($ct, 'application/json') == 0) {
$read_body_sub->();
my $from_json = $self->{raw_body};
if (substr($self->{raw_body}, 0, 2) eq '%7') {
$from_json =~ tr/+/ /;
$from_json =~ s/%([a-fA-F0-9]
#!/usr/bin/perl
use DBIx::Connector;
use Locale::PO;
use JSON;
use Encode;
use SQL::Abstract;
my $dbuser = ((getpwuid $>)[0]);
my $dbname = $dbuser;
my $dbpass = "";
my $conn;
my $fname;
my $language
_json($msgstr) ne $nls_message->{message_json}) {
$conn->run(
sub {
$_->do(
'update nls_message set message_json = ? where id_nls_msgid = ? and short = ?',
undef, to_json(
ert into nls_message (id_nls_msgid, short, message_json) values(?, ?, ?)',
undef, $nls_msgid->{id_nls_msgid},
$nls_lang->{short}, to_json($msgstr)
);
}
);
++$inserted;
}
mail-address,first-name,last-name,formatted-name,picture-url)';
$req->uri->query_form(format => 'json');
$req->header(Authorization => 'Bearer ' . $self->{session}->data->{oauth_access_token}{$self-
e}),
client_secret => cfg_oauth_client_secret($self->{service})
],
Accept => 'application/json';
}
sub _get_user_info_request {
my ($self) = @_;
my $req = GET 'https://api.github.com/user',