#!/usr/bin/env perl
use v5.14;
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use Path::Tiny;
my ($token, $list) = @ARGV;
die "Usage: $0 <token> <file>\n" if not $list;
my $ua = HTTP::Tiny->new
t = to_json( \%data );
my $res = $ua->post(
"https://api.metacpan.org/user/favorite?access_token=$token",
{ content => $post, headers => {'content-type' => 'application/json' }},
CPAN::API</a> to
abstract</p>
<pre class="brush: perl">my $ua = LWP::UserAgent;
my $me = decode_json(
$ua->get( 'https://api.metacpan.org/author/YANICK'
)->content;
</pre>
<p>into</p>
<
or>
error message, if C<$self->status> is I<Error>
=back
=head1 DEPENDENCIES
L<HTTP::Tiny>, L<JSON>, L<Log::Any>, L<Moo>, L<Try::Tiny>
=head1 LOGGING
This module uses the L<Log::Any> Framework
AND COPYRIGHT
GNU GPL V3
Peter Mayr 2016
=cut
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use Log::Any;
use Moo;
use Try::Tiny;
extends 'WebService::Lobid';
has isil => ( is => 'rw', p
LD {
my $self = shift;
my $query_string = undef;
my $response = undef;
my $json_result = undef;
my $result_ref = undef;
my $no_of_results = undef;
my %data
e Browser::Open qw(open_browser open_browser_cmd);
use Cwd qw(getcwd);
use Cpanel::JSON::XS qw(encode_json decode_json);
use Data::Dumper qw(Dumper);
use File::HomeDir ();
use File::Spec ();
use Path:
s);
my $home = File::HomeDir->my_home;
my $config_file = File::Spec->catfile($home, '.perltidy-tk.json');
my @options = ('indent-columns', 'paren-tightness', 'brace-tightness', 'block-brace-tightness'
;
usage() if $help;
my $config = {};
if (-e $config_file) {
$config = decode_json(path($config_file)->slurp_utf8);
}
$self->{autotidy} = 0;
$self->load_default_confi
5.008001;
our $VERSION = '0.65';
use Carp qw(croak);
use URI ();
use LWP::UserAgent;
use JSON::MaybeXS 'JSON';
use HTML::Entities qw/decode_entities/;
use HTTP::Request;
use MIME::Type;
$Carp::Inte
>_is_new($content)) {
my $args = $self->_get_args($content);
my $player_resp = JSON()->new->decode($args->{player_response});
$video_url_map = $self->_decode_player_response(
s*=\s*(\{.*})/) {
($data, undef) = JSON->new->utf8(1)->decode_prefix($1);
last;
}
}
croak 'failed to extract JSON data' unless $data->{args};
return $data
------+-----------'
# unknown code
% list_countries.pl --code xx
# output json
% list_countries.pl --code id --json
[200, "OK", [{"en_name":"Indonesia","code":"id","id_name":"Indonesia"}]
=hea
(
[ 'json|j' => 'stream output as JSON' ] ,
);
}
sub _execute {
my( $self, $opt, $args ) = @_;
if ( $self->opt->json ) {
try_load_class( 'JSON::MaybeXS' )
or die "json serializi
ng requires the module 'JSON::MaybeXS' to be installed\n";
my @data = map { {%$_} } $self->active_repos;
say JSON::MaybeXS->new(pretty => 1)->encode( \@data );
return;
}
for my $re
# Symbols processed
);
}
sub dumpAsJson($) # Create a JSON string representing a B<$dfa>.
{my ($dfa) = @_;
finalStates}{$state} = $$dfa{$state}->final; # Final states
}
encodeJson($jfa);
}
sub removeDuplicatedStates($) #P Rem
# Not in a final state
ok $dfa->dumpAsJson eq <<END, q(dumpAsJson); # Dump as json
{
"finalStates" : {
"0" : null,
"1" :
},
encode_json => sub {
if ( eval 'use JSON::MaybeXS 1.003000 (); 1' ) {
return \&JSON::MaybeXS::encode_json;
}
require JSON::PP;
return \&JSON::PP::encode_json;
},
decode_json => sub {
if ( eval 'use JSON::MaybeXS 1.003000 (); 1' ) {
return \&JSON::MaybeXS::decode_json;
}
require JSON::PP;
return \&JSON::PP::decode_json;
},
STRICT => sub {
$STRICT ? sub () { !!1 } : s
<Data::Dumper>, C<maybe> and C<provided> from
L<PerlX::Maybe>, C<encode_json> and C<decode_json> from
L<JSON::MaybeXS> or L<JSON::PP> (depending which is installed), and
C<STRICT> and C<LAX> from L<De
more information about JWTs and revoking tokens see
L<https://auth0.com/blog/2015/03/10/blacklist-json-web-token-api-keys/> and
L<https://tools.ietf.org/html/rfc7519>. Ultimately you're going to have
uth 2.0 Client Authentication and Authorization Grants.
L<https://tools.ietf.org/html/rfc7523> - JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants.
L<https://
if ( $file =~ /\.json$/i ) {
my $decode =
eval { require JSON::MaybeXS }
? \&JSON::MaybeXS::decode_json
: do { require JSON::PP; \&JSON::PP::decode_json };
return $decode-
override it to return a list of filenames (not full path names, just
simple filenames like "myapp.json"), your app will use these filenames to
find configuration settings.
=item C<< find_config >>
I
s allows your system-wide config in C<< /etc/myapp.json >> to be overridden
by user-specific C<< ~/.config/myapp.json >> and a local C<< ./myapp.json >>.
You should rarely need to call this manually.
use Data::Printer alias => 'pdump';
use File::Temp 'tempfile', 'tempdir';
use Hash::DotPath;
use JSON;
use YAML ();
use Ansible::Util::Run;
with 'Ansible::Util::Roles::Constants';
#################
rated tempfiles for debugging/troubleshooting. The tempfiles
used are a playbook, template, and json output.
=over
=item type: Bool
=item required: no
=item default: 0
=back
=cut
has keepTemp
nice_json }} ";
}
$self->File->write( $templateFilename, join( "\n", @content ) );
#
# create a placeholder for the template output
#
my $outputFilename = $self->_getTempFile('-output.json');
(
# 'geometry' => $self->{top}->geometry,
# );
# path($config_file)->spew(encode_json(\%config));
exit;
}
1;
=head1 NAME
App::Tk::Deparse - Tk based GUI to experiment with B::
n the config file and next time we use that size to open the application.
~/.perl-tk-deparse.json
=head1 SEE ALSO
L<B::Deparse>
L<Tk>
L<Tk::HyperText>
=head1 COPYRIGHT AND LICENSE
Copyrigh
:Crumbr
use strict;
use Carp;
use Scalar::Util qw< reftype blessed >;
sub json_leaf_encoder {
require B;
return \&_json_leaf_encode;
}
{
my $slash_escaped;
BEGIN {
$slash_escaped
0x0A => 'n',
0x0D => 'r',
0x09 => 't',
};
} ## end BEGIN
sub _json_leaf_encode {
return 'null' unless defined $_[0];
my $reftype = ref($_[0]);
re
, $lo;
}
} split //, $_[0];
return qq<"> . $string . qq<">;
} ## end sub _json_leaf_encode
}
sub uri_encoder {
require Encode;
return \&_uri_encoder;
}
{
my %is_unre
:URI::VERSION = '0.1.2';
# ABSTRACT: "JSON" profile for Data::Crumbr::Default
use Data::Crumbr::Util;
sub profile {
my $json_encoder = Data::Crumbr::Util::json_leaf_encoder();
my $uri_encoder
_encoder,
value_encoder => $json_encoder,
};
} ## end sub profile
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Data::Crumbr::Default::URI - "JSON" profile for Data::Crumbr::Default
h_vars >;
use Scalar::Util qw< blessed >;
use Data::Crumbr::Util;
my $jenc = Data::Crumbr::Util::json_leaf_encoder();
my $ienc = Data::Crumbr::Util::id_encoder();
has array_open => (default =
')->($data);
# here/hey "you"
# here/what "ever"
# JSON profile produces valid JSON "slices"
$encoded = crumbr(profile => 'JSON')->($data);
# {"here":{"hey":"you"}}
# {"here":{"what
[ 1..3 ],
something => "funny \x{263A} ☻",
},
};
If you encode this e.g. in JSON, it will be easy to parse with
the right program, but not from the shell, even if you pretty
prin
m *
hash keys encoded as JSON strings, surrounded by curly brackets:
hash_key_prefix => '['
hash_key_suffix => ']'
hash_key_encoder => Data::Crumbr::Util::json_leaf_encoder
=item *
n
= '0.0401';
use strict;
use warnings;
use 5.012;
use LWP::UserAgent;
use URI;
use JSON::MaybeXS qw(encode_json);
sub notify
{
my $class = shift;
my ($args) = @_;
my $base_url = $arg
if ( defined($msg) )
{
push @$query,
( text_params => scalar( encode_json( { msg => $msg, } ) ) );
}
$url->query_form($query);
my $response = $ua->get($url);
>connector->_ua_get($self->url);
Carp::confess $res->message if $res->is_error;
return $res->json;
}
1;
=encoding utf8
=head1 NAME
Nuvol::Office365::Drive - Internal methods for Office 365 dr
=back
=head2 Planned additional drivers
=over
=item *
SSH/SFTP
=item *
IMAP
=item *
JSON/YAML files (i.e. browse data structure)
=item *
Zip/archive
=item *
Multipart/MIME
=back