ny ();
use Text::CleanFragment qw/clean_fragment/;
use Regexp::Common qw/balanced delimited/;
use JSON::MaybeXS ();
use XML::LibXML ();
use Data::Dump qw/dd/;
# Badge-Simple 0.01 had a ton of CPAN Te
my $GET_CACHE = dir($FindBin::Bin,'scrape_cache'); # for sub get
$GET_CACHE->mkpath(1);
my $json = JSON::MaybeXS->new(relaxed=>1);
my $cpt_js = get('http://www.cpantesters.org/static/distro/B/Badg
ons = $json->decode($1);
my $version = $versions->[-1];
$cpt_js =~ m{ \b var \s+ results \s* = \s*
( $RE{balanced}{-parens=>'{}'} ) \s* (?: ; | \z ) }xms
or die $cpt_js;
my $reports = $json->decod
->routes->post(
'/dummy/mail/*domain/messages' => sub {
my $c = shift;
$c->render(json =>
{id => 1, params => $c->req->params->to_hash, url => $c->req->url->to_abs});
}
package typedjson;
# based on code from EDG::WP4::CCM::Fetch::JSONProfileTyped
# (and EDG::WP4::CCM::Fetch::ProfileCache::_decode_json)
# for an explanation and original code, see
# https://github.c
l/Fetch/JSONProfileTyped.pm
# This was ported and modified here because CCM is not that trivial to install from source
use strict;
use warnings;
use JSON::XS v2.3.0 qw(decode_json encode_json);
use
parent qw(Exporter);
our @EXPORT = qw(process_json);
use B;
use Scalar::Util qw(blessed);
$SIG{__DIE__} = \&confess;
# Turns a JSON Object (an unordered associative array) into a Perl hash
# refe
que::Plugin::Delay::Dequeue;
use 5.008001;
use strict;
use warnings;
use Moose::Role;
use JSON qw/decode_json/;
around pop => sub {
my ( $orig, $self, $queue ) = @_;
my $payload = $self->red
is->lpop($self->key( queue => $queue ));
return unless $payload;
$payload = decode_json($payload);
my $job = $self->new_job({
payload => $payload,
queue => $queue
})
use Compress::LZF;
use Scalar::Util ();
use Socket ();
use Deliantra::Protocol::Constants;
use JSON::XS ();
=item new Deliantra::Protocol::Base host => ..., port => ..., user => ..., pass => ...
ken => "a",
s_version => { },
tilesize => 32,
json_coder => (JSON::XS->new->max_size(1e7)->utf8),
@_
}, $class;
$self->{fh_guard} = AnyEvent
ragmented packets
%{$self->{setup_req} || {} },
};
$self->send ("version " . $self->{json_coder}->encode ({
protver => 1,
client => "Deliantra Perl Module [$0]",
package WebService::HMRC::Request;
use 5.006;
use Carp;
use JSON::MaybeXS qw(encode_json);
use LWP::UserAgent;
use Moose;
use namespace::autoclean;
use URI;
use WebService::HMRC::Response;
=head1 N
s_success;
# post data as json to an application-restricted endpoint
my $data = {serviceNames => ['mtd-vat']};
my $response = $r->post_endpoint_json({
endpoint => '/create-tes
ethods for calling api endpoints, mapping their response
into a standard class and decoding their JSON payload. It also provides a
LWP::UserAgent with appropriate headers set and a lower-level method
$TILE *FACE *FACEDATA
TILESIZE CACHESTRIDE
editor_archs arch_extents
);
use JSON::XS qw(decode_json encode_json);
our $LIB = $ENV{DELIANTRA_LIBDIR};
our $VARDIR = $ENV{HOME} ? "$ENV{HOME}/
'eq' => sub { "$_[0]" eq "$_[1]" },
'ne' => sub { "$_[0]" ne "$_[1]" },
;
sub TO_JSON {
$_[0][0]
}
}
sub Deliantra::MoveType::new {
my ($class, $string) = @_;
my $mas
e archetype
if (exists $ob->{attach}) {
my $arch = $ARCH{$ob->{_name}};
my $js = JSON::XS->new->utf8->canonical (1);
if (defined $arch->{attach}
&& $js->encode ($js->
tion::DBManager::Grammar $text;
}
);
return $filter if ($opts{'type'} || '') eq 'json_data';
return $self->_get_db_filter_from_data(
$filter, %opts,
model_fields
th qw(make_path);
use Config::INI::Reader;
use Data::Dumper;
use Template;
use Readonly;
use typedjson;
my $debug = 1;
Readonly my $GEN_API_DIR => dirname(abs_path($0));
Readonly my $API_DIR => "$GE
options from JSON
my $json = $mcfg->{json};
if ((grep {$mcfg->{method} eq $_} @METHODS_REQUIRE_OPTIONS) && !$json) {
die "$err_prefix data should contain JSON for options
for method $method $mcfg->{method}";
}
$mcfg->{options} = process_json($json, $templates) if $json;
foreach my $kn (sort keys %{$mcfg->{options}}) {
if (grep {$_ eq
Accept') || '') =~ /(application\/json|text\/javascript)/) {
$self->response->content_type("$1; charset=UTF-8");
$self->response->data(to_json({error => $exception->message()})
Accept') || '') =~ /(application\/json|text\/javascript)/) {
$self->response->content_type("$1; charset=UTF-8");
$self->response->data(to_json({error => gettext('Internal Serve
ck::Client::Request;
# cannot use 'use Types::Serialiser'; it is incompatible with JSON::XS 2.X (eg on EL6)
use JSON::XS;
use Readonly;
use base qw(Exporter);
our @EXPORT_OK = qw(convert process_ar
ce internal conversion to float/double
boolean => sub {my $val = shift; return $val ? JSON::XS::true : JSON::XS::false;},
};
# Aliases for each dispatch
Readonly::Hash my %CONVERT_ALIAS => {
};
ptions
# The processed options are removed from %origopts
# TODO: naming conflict between JSON key, parameter and template name? (handled in gen.pl)
foreach my $name (@{$cmdhs->{templates}
=> {
$HDR_ACCEPT => 'application/json, text/plain',
$HDR_ACCEPT_ENCODING => 'identity, gzip, deflate, compress',
$HDR_CONTENT_TYPE => 'application/json',
};
=head1 NAME
Net::OpenStack::
";
}
return $endpoint;
}
=item opts_data
Generate hashref from options, to be used for JSON encoding.
If C<raw> attribute is defined, ignore all options and return it.
Returns empty hasref
s
=item No optional url / endpoint parameters
=item Options
=over
=item raw: hashref used for JSON body, ignoring all options
=item All options starting with C<__> are passed as options to C<Net:
DR_X_AUTH_TOKEN);
use Net::OpenStack::Client::Response;
use REST::Client;
use LWP::UserAgent;
use JSON::XS;
use Readonly;
# Map with HTTP return codes indicating success
# if method is missing (on
=> [204, 201], # yes, 201 when deleting a token
};
# JSON::XS instance
# sort the keys, to create reproducable results
my $json = JSON::XS->new()->canonical(1);
=head1 methods
=over
=cut
su
e repsonse, repsonse headers and error message.
# Processes the repsonse code, including possible JSON decoding
# Reports error and returns err (with repsonse undef)
sub _call
{
my ($self, $method
ew(@_);
}
=item new
Create new error instance from options, e.g. from a (decoded dereferenced) JSON response.
Arguments are handled by C<set_error>.
=cut
sub new
{
my $this = shift;
my $
in/.openrc',
log => Log::Log4perl->get_logger()
);
For debugging, including full JSON request / repsonse and headers (so contains sensitive data!):
use Net::OpenStack::Client;
($text);
}
sub as_json {
my ($self, $data) = @_;
$self->response->content_type('application/json; charset=UTF-8');
$self->response->data(to_json($data));
}
sub as_jsonp {
my ($self,
response->content_type('text/javascript; charset=UTF-8');
$self->response->data("$func(" . to_json($data) . ')');
}
sub from_template {
my ($self, $name, %opts) = @_;
$self->response->da
}
return $dump_text;
},
to_json => sub {
return to_json(shift);
},
cmd_link => sub {
my ($new
package Exception::BadArguments::InvalidJSON;
$Exception::BadArguments::InvalidJSON::VERSION = '2.8';
use base qw(Exception::BadArguments);
=head1 Name
qbit::StringUtils - Functions to manipulate st
use JSON::XS ();
use POSIX qw(locale_h);
BEGIN {
our (@EXPORT, @EXPORT_OK);
@EXPORT = qw(
html_encode html_decode uri_escape check_email idn_to_unicode get_domain to_json from_json for
e {
return;
}
}
=head2 to_json
B<Arguments:>
=over
=item
B<$data> - scalar.
=back
B<Return value:> string, C<$data> as JSON.
=cut
sub to_json($;%) {
my ($data, %opts) = @_;
ption: string (JSON path: domain -> description)
=item enabled: boolean (JSON path: domain -> enabled)
=item name: string (JSON path: domain -> name)
=item raw: hashref used for JSON body, ignoring
ion: string (JSON path: project -> description)
=item domain_id: string (JSON path: project -> domain_id)
=item enabled: boolean (JSON path: project -> enabled)
=item name: string (JSON path: proje
ct -> name)
=item parent_id: string (JSON path: project -> parent_id)
=item raw: hashref used for JSON body, ignoring all options
=item All options starting with C<__> are passed as options to C<Ne