actJSON;
use 5.010;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(format_pretty);
our $VERSION = '0.12'; # VERSION
sub content_type { "application/json"
ata, $opts) = @_;
state $json;
$opts //= {};
if ($opts->{color} // $ENV{COLOR} // (-t STDOUT)) {
require JSON::Color;
JSON::Color::encode_json($data, {pretty=>0, linum=>0
});
} else {
if (!$json) {
require JSON::MaybeXS;
$json = JSON::MaybeXS->new->utf8->allow_nonref;
}
$json->encode($data);
}
}
1;
# ABSTRACT: Pr
); # SvTYPE is IV or NV?
my $type = ref($value);
if (!$type) {
return string_to_json($value);
} elsif ($type eq 'ARRAY') {
return sprintf('[%s]', join(", ", map { _serial
\f',
"\b" => '\b',
"\"" => '\"',
"\\" => '\\\\',
"\'" => '\\\'',
);
sub string_to_json {
my ($arg) = @_;
$arg =~ s/([\x22\x5c\n\r\t\f\b])/$esc{$1}/g;
$arg =~ s/([\x00-\x08
00;
use strict;
use warnings;
use parent qw/Exporter/;
use Carp;
use HTTP::Tiny;
use JSON::MaybeXS qw/decode_json/;
use Scalar::Util qw/looks_like_number/;
use WebService::TDWTF::Article;
my @subs =
nse = $ht->get($url);
croak $response->{reason} unless $response->{success};
$response = decode_json $response->{content};
croak $response->{Status} if ref $response eq 'HASH' && !exists $response-
e Text::CSV::Flatten;
use v5.014;
use strict;
use warnings;
our $VERSION = '0.04';
use JSON qw/ encode_json /;
use Text::CSV;
my @KNOWN_ARGS= qw/ column_name /;
sub new {
my ($class, $pattern
} elsif($it->can('TO_JSON')) {
no warnings 'prototype'; # avoid "_foreach() called too early to check prototype"
_foreach($codeblock, $it->TO_JSON);
} else {
ror";
}
} else {
my $cell_value= ref $cur_data
? encode_json($cur_data)
: $cur_data;
my @column_tuple= @$column_name_prefix ? @$
pan-meta/issues/28
# but this is the current v2.0 spec - regexp lifted from Test::CPAN::Meta::JSON::Version
$self->log_fatal('invalid syntax for optional feature name \'' . $self->name . '\''
##########
#JSON Graph Specification file format methods #
#############################################################################
{
use JSON;
sub inp
}
my $json_text = $EMPTY_STRING;
open(my $infile, '<:encoding(UTF-8)', $filename) or croak "could not open '$filename'";
print {$verboseOutfile} "inputGraphfromJSON: opened '$file
y $line = <$infile>) {
$json_text .= $line;
}
close($infile);
my $graphHref = from_json( $json_text, {utf8 => 1} ) or croak "inputGraphfromJSON: invalid json text";
if (ref($gra
to use when encrypting the JSON data being sent to the
Pandora API method.
=item decryption_key =E<gt> STRING [required]
The decryption key to use when decrypting the JSON data send back from the
Pa
h2::VERSION = '3.05';
use strict;
use warnings;
# ABSTRACT: OAuth2 for Google Analytics API
use JSON;
use LWP::UserAgent;
use URI;
sub new {
my $class = shift;
my $self = { @_ };
die(
;
die('error getting token: ' . $res->status_line) unless $res->is_success;
return from_json($res->decoded_content);
}
sub refresh_access_token {
my ($self, $refresh_token) = @_;
m
;
die('error getting token: ' . $res->status_line) unless $res->is_success;
return from_json($res->decoded_content);
}
sub interactive {
my $self = shift;
my $url = $self->authoriz
N
B<WebService::Pandora> is a module to communicate with the Pandora (L<http://www.pandora.com>) JSON API.
The API is not officially published, and has a few oddities, but was reverse engineered and
e::Pandora::Method;
use WebService::Pandora::Cryptor;
use WebService::Pandora::Partner::iOS;
use JSON;
use Data::Dumper;
our $VERSION = '0.4';
### constructor ###
sub new {
my $caller = shift
deExtendedAttributes'};
$includeExtendedAttributes = ( $includeExtendedAttributes ) ? JSON::true() : JSON::false();
# make sure they provided a stationToken argument
if ( !defined( $stat
Positive must be specified.' );
return;
}
$isPositive = ( $isPositive ) ? JSON::true() : JSON::false();
# create the station.addFeedback method w/ appropriate params
my $meth
Mojolicious::Plugin::Pingen;
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::UserAgent;
use Mojo::JSON;
use POSIX qw(strftime);
use Mojo::Exception;
use constant DEBUG => $ENV{MOJO_PINGEN_DEBUG} || 0;
d2 pingen.document.upload
my $json = $c->pingen->document->upload($asset[,\%args]);
$c->pingen->document->upload($mojoUpload[,\%args], sub { my ($c, $json) = @_; });
Upload a L<Mojo::Uploa
DF file). Pingen will analyze the content of the pdf and figure out
how and where to mail it.
C<$json> is the response object from pingen.
C<%args> can contain the following optional parameters:
=
rict;
use warnings;
# ABSTRACT: Simple interface to the Google Analytics Core Reporting API
use JSON;
use LWP::UserAgent;
use Net::Google::Analytics::Request;
use Net::Google::Analytics::Response;
u
http_res->decoded_content);
return $res;
}
my $json = from_json($http_res->decoded_content);
$res->_parse_json($json);
$res->start_index($start_index);
$res->is_success(1
L<WebService::TDWTF>. Each such object is guaranteed to
be a blessed hashref corresponding to the JSON returned by the TDWTF
API (possibly with some extra keys), so the data inside can be
obtained by
::Cryptor> is used to encrypt and decrypt the data sent to and from
the Pandora JSON API. Some methods require the JSON to be sent using the Blowfish
algorithm in ECB mode. Some of the attributes re
is passed
a true value for the B<encrypt> boolean, it uses this module to do so for the submitted
JSON data.
=head1 CONSTRUCTOR
=head2 new
Creates a B<WebService::Pandora::Cryptor> object with the
encrypted string of the JSON data given that the Pandora
API expects, using the provided B<encryption_key> specified in the constructor.
$encrypted = $cryptor->encrypt( $json_str );
=head2 decrypt
}
sub _parse_json {
my ($self, $json) = @_;
$self->items_per_page($json->{itemsPerPage});
$self->total_results($json->{totalResults});
$self->contains_sampled_data($json->{containsSa
a});
$self->profile_info($json->{profileInfo});
my $json_totals = $json->{totalsForAllResults};
my %totals;
while (my ($json_name, $total) = each(%$json_totals)) {
my $column
al;
}
$self->_totals(\%totals);
my @column_headers;
for my $column_header (@{ $json->{columnHeaders} }) {
push(@column_headers, {
name => _parse_column_na
WebService::FritzBox;
# ABSTRACT: Interface to FritzBox devices
use Digest::MD5 qw/md5_hex/;
use JSON::MaybeXS;
use LWP::UserAgent;
use Log::Log4perl;
use Moose;
use MooseX::Params::Validate;
use Try
ata = decode_json( $response->decoded_content );
# It's just an array with one element...
$data = $data->[0];
}catch{
$self->log->logdie( "Could not decode json: $_" );
or() );
=head1 DESCRIPTION
B<WebService::Pandora::Method> is a module which queries the Pandora JSON API using the
B<LWP::UserAgent> and B<HTTP::Request> libraries. It is used by the main B<WebServ
dule for all of the webservice methods it exposes. It handles all of the encryption,
decryption, JSON conversion, and the Pandora API oddities for you.
=head1 CONSTRUCTOR
=head2 new
Creates a new
iven. The method can
then be B<execute()>ed, returning a decrypted hashref representation of the JSON string returned
by the Pandora API method.
$method = WebService::Pandora::Method->new( name =>
es> documentation to know more about swat meta stories.
=head1 Advanced usage
=head2 handling json responses
Modify Kelp controller
=head3 GET /user/id
$ cat user/id/get.pm
my ($s
$id}->{age}
}
Add json handler to swat test:
$ cat user/id/get.handler
my $headers = shift;
my $body = shift;
use JSON;
$hash = decode_json($body);
return "$h
ice::Pandora::Method;
use strict;
use warnings;
use WebService::Pandora::Cryptor;
use URI;
use JSON;
use HTTP::Request;
use LWP::UserAgent;
use Data::Dumper;
### constructor ###
sub new {
my
= LWP::UserAgent->new( timeout => $self->{'timeout'} );
# create and store json object
$self->{'json'} = JSON->new();
return $self;
}
### getters/setters ###
sub error {
my ( $se
.' );
return;
}
# craft the json data accordingly
my $json_data = {};
if ( defined( $self->{'userAuthToken'} ) ) {
$json_data->{'userAuthToken'} = $self->{'userAuthT
ient::Simple;
# ABSTRACT: a client that submits to Metabase servers
our $VERSION = '0.012';
use JSON::MaybeXS;
use HTTP::Tiny 0.056; # can_ssl
use URI;
my @valid_args;
BEGIN {
@valid_args = qw
=> {
Content_Type => 'application/json',
Accept => 'application/json',
},
content => JSON::MaybeXS->new( { ascii => 1 } )->encode( $fact->
=> {
Content_Type => 'application/json',
Accept => 'application/json',
},
content => JSON::MaybeXS->new( { ascii => 1 } )
->