use strict;
use warnings;
use Test::More;
use typedjson;
my $txt = '{"a":{"b":1,"c":true},"d":{"b":"what","e":[1,2]}}';
my $result = {
a_b => {'path' => ['a', 'b'], 'type' => 'long'},
c =>
};
my $parsed = typedjson::parse_json($txt);
#diag "parsed ",explain $parsed;
is_deeply($parsed, [$result->{a_b}, $result->{c}, $result->{d_b}, $result->{d_e}], "parse_json returns list of scalars
");
my $options = process_json($txt, ['e']);
#diag "options ",explain $options;
is_deeply($options, $result, "generated options hashref");
done_testing();
ype' => (
isa => Enum[qw{application/json application/xml application/yaml application/x-www-form-urlencoded}],
is => 'rw',
default => sub { 'application/json' },
);
has clientattrs => (
isa =>
$foo = RESTExample->new(
server => 'http://localhost:3000',
type => 'application/json',
clientattrs => {timeout => 5},
);
$foo->bar;
# controller
sub foo : Local {
my ($self
PUT
POST
DELETE
OPTIONS
Currently Role::REST::Client supports these encodings
application/json
application/x-www-form-urlencoded
application/xml
application/yaml
x-www-form-urlencoded only
tion = $attr eq 'enabled' ? ($wa xor $fo): ($wa ne $fo);
# hmmm, how to keep this JSON safe?
$update->{$attr} = $wa if $action;
}
if (scalar key
package WebService::HMRC::Response;
use 5.006;
use Carp;
use JSON::MaybeXS qw(decode_json);
use Moose;
use namespace::autoclean;
use Try::Tiny;
=head1 NAME
WebService::HMRC::Response - Response ob
erl hash representing an api call's json response.
This property is updated on object creation when the http property is set.
If an api call returns no valid json response, this property is
populate
lass's `data` property to reflect the json content of
# the supplied HTTP::Response object. Returns a reference to the Perl data
# structure representing the json response.
sub _parse_http_response {
t.
An example is given in the distribution for using this class with L<Mojo::Pg::PubSub> to relay JSON messages between web-based chat clients.
As this module is low level it does no character encodi
use WWW::Mechanize;
use Type::Tiny;
use Types::Standard -types;
use URI;
use WWW::Mechanize;
use JSON;
use Try::Tiny;
our $VERSION = '0.10';
has url => (
is => 'rw',
required => 1,
=> 'rw',
);
sub BUILD {
my ($self) = @_;
$self->mech->add_header(accept => 'application/json');
if ($self->url =~ m{/$}) {
my $url = $self->url;
$url =~ s{/$}{};
->url . '/api/' . $api);
$uri->query_form(%params);
$mech->get($uri);
return decode_json($mech->content || '{}');
}
sub _post {
my ($self, $api, %params) = @_;
my $mech = $self
TA.json');
my $metajson = first { blessed($_) eq 'Dist::Zilla::Plugin::MetaJSON' } @{ $self->zilla->plugins };
return (0, 'META.json is not being added to the distribution') if not $metajson;
return (0, [ 'META.json is using meta-spec version %s', $metajson->version ]) if $metajson->version < '2';
my @filenames = map { $_->name } @{ $self->zilla->files };
$self->$log('checkin
no other plugins may modify F<Makefile.PL> nor F<Build.PL>
=item *
the L<C<[MetaJSON]>|Dist::Zilla::Plugin::MetaJSON> plugin must be used, at (the default) meta-spec version 2
=item *
no F<.xs> fi
var self = this;
socket.onmessage = function (e) {
channel.messages.push(JSON.parse(e.data));
if ( channel !== self.current ) { channel.unread++ }
};
l;
channel.unread = 0;
},
send: function() {
this.current.socket.send(JSON.stringify({username: this.username, message: this.message}));
this.message = '';
},
=item *
C<js_JSON> - whether to use native JSON encoder of Firefox
js_JSON => 'native', # force using the native JSON encoder
The default is to autodetect whether a native JSON encoder is ava
if (! ref $args{ app }) {
my @passthrough = qw(launch repl bufsize log use_queue js_JSON);
my %options = map { exists $args{ $_ } ? ($_ => delete $args{ $_ }) : () }
$encoding)";
# Switch on UTF-8 flag
# This should never happen, as JSON::XS (and JSON) should always
# already return proper UTF-8
# But it does happen.
to false. If set
to a true value, The results show on the HTML page can be downloaded as
CSV/TSV/JSON/XML. The download links will appear at the top of the page.
=item C<foreign_keys>
A hashref to
my $page = uri_escape(params->{'p'} || 0);
my @formats = qw/csv tabular json xml/;
my $url = _external_url($args->{dancer_prefix}, $args->{prefix})
. "?o
ormat eq "json") {
header('Content-Type' => 'text/json');
header('Content-Disposition' =>
"attachment; filename=\"$filename.json\"");
$output = to_json($sth->fe
ape.pl http://perl.org a[@href=$"jpg"]
# print JSON about Amazon prices
scrape.pl https://www.amazon.de/dp/0321751043
--format json
--name "title" #productTitle
--name
price
--name "deal" #priceblock_dealprice
# print JSON about Amazon prices for multiple products
scrape.pl --format json
--url https://www.amazon.de/dp/B01J90P010
--ur
=> $url,
url_field => $url_field,
});
};
if( 'json' eq $format ) {
require JSON;
print JSON::encode_json(\@rows);
} else {
require Text::CSV_XS;
Text::CSV_XS->imp
" -H 'Connection: close' " .
" -H 'Content-Type: application/json' " .
" $url";
print "$cmd\n";
system( $cmd );
print
nection => "close" );
$ua->default_headers->push_header( "Content-Type" => "application/json" );
# add ACCESS_SIGNATURE in a request_prepare handler so we can set it knowing the req
$request_data->{serviceNames} = $args->{services};
}
return $self->post_endpoint_json({
endpoint => $endpoint,
data => $request_data,
auth_type => 'application
il' => $self->email,
'X-Auth-Key' => $self->key,
'Content-Type' => 'application/json',
};
$header->{'X-Auth-User-Service-Key'} = $self->user_service_key if $self->user_servic
) {
@extra = (json => $params);
}
my $tx = $self->ua->build_tx($method => $url => $header => @extra );
$tx = $self->ua->start($tx);
return $tx->res->json if ($tx->res->header
s->content_type || '') =~ /json/;
return $tx->res->body if ($tx->res->headers->content_type || '') =~ /application\/octet-stream/;
my $err = $tx->error;
croak "$err->{code} response: $err
e warnings;
our $VERSION = '1.03';
use Carp qw(croak);
use JSON;
use Scalar::Util qw(reftype);
use RedisDB;
use Try::Tiny;
my $json = JSON->new->utf8->allow_nonref;
sub TIEHASH {
my ($self, $ad
key);
return $val && $json->decode($val);
}
sub STORE {
my ($self, $key, $val) = @_;
my $redis = $self->{REDIS};
$redis->hset($self->{WHERE}, $key, $json->encode($val));
if (my
To help to build fixtures
# $fixtures->dump({
# config => 'all_tables.json', # config file to use. must be in the config
# # director
k for use with native
and hybrid mobile apps. It drives iOS and Android apps using the
WebDriver JSON wire protocol. This module is a thin extension of
L<Selenium::Remote::Driver> that adds Appium sp
s;
$Appium::Commands::VERSION = '0.0804';
# ABSTRACT: Appium specific extensions to the Webdriver JSON protocol
use Moo;
extends 'Selenium::Remote::Commands';
has 'get_cmds' => (
is => 'lazy',
pod
=encoding UTF-8
=head1 NAME
Appium::Commands - Appium specific extensions to the Webdriver JSON protocol
=head1 VERSION
version 0.0804
=head1 DESCRIPTION
There's not much to see here. View
s logic to talk to Overheid.IO
our $VERSION = '1.2';
use LWP::UserAgent;
use URI;
use Carp;
use JSON;
has ua => (
is => 'ro',
isa => 'LWP::UserAgent',
builder => '_build_use
("%s - %s", $res->status_line, $res->decoded_content), $/;
}
my $json = JSON->new->decode($decoded);
return $json;
}
__PACKAGE__->meta->make_immutable;
__END__
=pod
=encoding UTF-8
en data initiative to expose
data the Dutch government exposes via a JSON API. This is a Perl
implemenation for talking to that JSON API.
=head1 ATTRIBUTES
=head2 ua
An L<LWP::UserAgent> object
=h
y $api = delete $args{ api };
if (! ref $args{ repl }) {
my @passthrough = qw(repl js_JSON launch);
my %options = map { exists $args{ $_ } ? ($_ => delete $args{ $_ }) : () }