package App::EventStreamr::Status;
use Method::Signatures;
use JSON;
use Scalar::Util::Reftype;
use Moo;
use namespace::clean;
# ABSTRACT: A status object
our $VERSION = '0.5'; # VERSION: Generated
fig->nickname;
my $json = to_json($status);
my %post_data = (
content => $json,
'content-type' => 'application/json',
'content-length' => length($json),
);
my $post
;
%post_data = (
content => to_json($data),
headers => {
'station-mgr' => 1,
'Content-Type' => 'application/json',
}
);
$post = $self->c
::Config;
use Method::Signatures;
use Sys::Hostname;
use experimental 'say';
use Config::JSON; # libconfig-json-perl
use File::Path qw(make_path);
use Carp 'croak';
use App::EventStreamr::Devices;
use
$self->devices_util->all();
}
method _build_config_file() {
return $self->config_path."/config.json";
}
method _build_nickname() {
return hostname || "default_name";
}
method _build_macaddress(
fig() {
# Config JSON barfs if you try to load a config that doesn't exist,
# this will load one or attempt to create it.
if ( -e $self->config_file ) {
return Config::JSON->new($self->confi
$self->serial_format($1);
}
else {
$self->serial_format('json');
}
}
# this ISA trickery has 2 benefits:
# (1) a default new() method
should serialized Perl values be assumed to be? The default is C<yaml>.
You might also specify C<json>. If you have serialized values in some other format,
then you'll need to subclass SWISH::API::Ob
se Test::More;
use LWP::UserAgent;
use HTTP::Request;
use LWP::Protocol::https;
use JSON;
use JSON::Parse 'parse_json';
use IO::Socket::SSL;
my $const_sin = "TeyN4LPrXiG5t2yuSamKqP3ynVk3F52iHrX";
my
$request->header('content-type' => 'application/json');
my %content = ('id'=>$sin);
my $jsonc = encode_json \%content;
$request->content($jsonc);
my $ua = LWP::UserAgent->new;
my $response
E
WWW::StatsMix - Interface to StatsMix API.
=head1 VERSION
Version 0.07
=cut
use 5.006;
use JSON;
use Data::Dumper;
use WWW::StatsMix::Stat;
use WWW::StatsMix::Metric;
use WWW::StatsMix::UserAg
an;
extends 'WWW::StatsMix::UserAgent';
has format => (is => 'ro', default => sub { return 'json' });
has metrics_url => (is => 'ro', default => sub { return 'http://api.statsmix.com/api/v2/metr
mat});
my $response = $self->post($self->metrics_url, [ %$params ]);
my $content = from_json($response->content);
return WWW::StatsMix::Metric->new($content->{metric});
}
=head2 update
}
elsif ($serializer eq 'JSON') {
require JSON::XS;
$serialize_methods = [\&JSON::XS::encode_json, \&JSON::XS::decode_json];
}
}
if ($serialize_
strict;
use warnings;
use base qw( SWISH::API::More::Results );
use Carp;
use YAML::Syck ();
use JSON::Syck ();
our $VERSION = '0.14';
*next = \&next_result;
sub next_result {
my $self = shift
ize\n$v";
}
return $s;
}
elsif ( $f eq 'json' && $v =~ m/^[\{\[\"]/o ) {
my $s;
eval { $s = JSON::Syck::Load($v); };
if ($@) {
croak "$@\nca
:UserAgent - StatsMix API user agent library.
=head1 VERSION
Version 0.07
=cut
use 5.006;
use JSON;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST PUT GET DELETE);
use WW
trict;
use warnings;
use 5.010;
use Carp;
use autodie;
use utf8;
use Moo;
use HTTP::Request;
use JSON;
use Net::HTTP::Spore;
use List::Util qw/first/;
use Scalar::Util qw/blessed weaken/;
use Data::U
default => sub { File::ShareDir::dist_file('WebService-Zaqar', 'marconi.spore.json') });
has 'client_uuid' => (is => 'ro',
lazy => 1,
bu
payloads serialized/deserialized to/from JSON -- except if
# you're receiving 401 or 403
$client->enable('+WebService::Zaqar::Middleware::Format::JSONSometimes');
# set X-Auth-Token heade
se Moo;
use Text::MarkdownTable;
use IO::Handle::Util ();
use IO::File;
use JSON::XS ();
with 'Catmandu::Exporter';
# JSON Table Schema
has schema => (
is => 'ro',
coerce => sub {
my
chema, "r");
die "failed to load JSON Table Schema from $schema" unless $fh;
local $/;
$schema = JSON::XS::decode_json(<$fh>);
}
$schema;
}
);
ne client:
echo '{"one":"my","two":"table"} {"one":"is","two":"nice"}' | \
catmandu convert JSON --multiline 1 to Table
| one | two |
|-----|-------|
| my | table |
| is | nice |
ints;
use YAML::Tiny;
use Data::Dumper;
enum 'Format', [qw(YAML XML JSON)];
enum 'Process', [qw(sox play)];
enum 'TTY', [qw(STDOUT STDERR)];
enum 'Handle', ['
rmat::JSONSometimes;
# ABSTRACT: middleware for JSON format
use JSON;
use Moose;
extends 'Net::HTTP::Spore::Middleware::Format';
has _json_parser => (
is => 'rw',
isa => 'JSON',
lazy => 1,
default => sub { JSON->new->utf8(1)->allow_nonref },
);
sub encode { $_[0]->_json_parser->encode( $_[1] ); }
sub decode { $_[0]->_json_parser->decode( $_[1] ); }
sub acc
ept_type { ( 'Accept' => 'application/json' ) }
sub content_type { ( 'Content-Type' => 'application/json;' ) }
sub should_serialize {
my $self = shift;
$self->_check_serializer( shift->env,
iny;
use constant DEFAULT_FORMAT => 'YAML';
enum 'Format', [qw(YAML XML JSON)];
has 'format' => (
is => 'rw',
isa => 'Format',
);
has 'p
die "Regrettably, this is not a valid format option. Choose one of ( [o] YAML, [x] JSON or [x] XML." if $@;
return(0);
}
sub begin {
my $self = shift
package Gcis::Client;
use Mojo::UserAgent;
use Mojo::Base -base;
use Mojo::Log;
use JSON::XS;
use YAML::XS qw/LoadFile/;
use Path::Class qw/file/;
use Data::Dumper;
use Time::HiRes qw/sleep/;
use v5.1
gger => sub { state $log ||= Mojo::Log->new(); };
has json => sub { state $json ||= JSON::XS->new(); };
has accept => "application/json";
has 'tx';
sub auth_hdr { ($a = shift->key) ? ("Autho
ssage});
return;
};
my $json = $res->json or do {
$s->logger->debug("no json from $path : ".$res->to_string);
$s->error("No JSON returned from $path : ".$res->to_string
.vmd.cookie", # Name of the file to restore cookies from and save cookies to
format => 'Perl', # JSON, XML or Perl. Perl by default
scope => 'friends,photos,audio,video,wall,groups,messages,offline'
package VK::App;
use strict;
use warnings;
use LWP;
use LWP::Protocol::https;
use JSON;
our $VERSION = 0.12;
sub new {
my ($class, %args) = @_;
die "USAGE:\nVK::App->new(api_id => .
rn $content if ($self->{format} eq "XML");
return $content if ($self->{format} eq "JSON");
return decode_json($content);
}
1;
__END__
#################### DOCUMENTATION ###############
l,groups,messages,offline',
# Data format that will receive as a result of requests 'JSON', 'XML' or 'Perl'.
# Perl object by default.
format => 'Perl',
);
s;
use WWW::Challonge;
use HTTP::Request::Common qw/POST/;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
sub __args_are_valid;
sub __is_kill;
=head1 NAME
WWW::Challonge::Match::Attachmen
keys %{$args};
my $request = POST(
"$HOST/tournaments/$url/matches/$match_id/attachments/$id.json",
"Content-Type" => 'form-data',
"Content" => [ "api_key" => $key, @params ],
);
$request->
all:
my $response = $client->delete(
"$HOST/tournaments/$url/matches/$match_id/attachments/$id.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response-
rvice::Instapaper;
use 5.008001;
use strict;
use warnings;
use OAuth::Lite::Consumer;
use JSON qw(decode_json);
use Carp qw(croak);
our $VERSION = "0.02";
my $endpoint = "https://www.instapaper.com
$self, %params) = @_;
my $res = $self->request('POST', '/bookmarks/list', \%params);
@{decode_json($res->decoded_content)->{bookmarks}};
}
sub add_bookmark {
my ($self, $url, %params) = @_;
$
t;
use LWP::UserAgent;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
use 5.010;
use strict;
use warnings;
sub __handle_error;
sub __json_request;
=head1 NAME
WWW::Challonge - Perl wrapp
to get some content and check the response code:
my $response = $client->get("$HOST/tournaments.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response-
->{key};
my $client = $self->{client};
# The intial request URL:
my $req = "$HOST/tournaments.json?api_key=$key";
# Loop through the options (if any) and add them on:
for my $option(keys %{$opt
use WWW::Challonge;
use WWW::Challonge::Match::Attachment;
use Carp qw/carp croak/;
use JSON qw/to_json from_json/;
sub __args_are_valid;
=head1 NAME
WWW::Challonge::Match - A class representing a
Make the PUT call:
my $response = $client->request(WWW::Challonge::__json_request(
"$HOST/tournaments/$url/matches/$id.json", "PUT", $params));
# Check for any errors:
WWW::Challonge::__han
tches/$id.json?api_key=$key");
# Check for any errors:
WWW::Challonge::__handle_error $response if($response->is_error);
# If not, save it and then return it:
$self->{match} = from_json($respons