:Result;
$Weather::OpenWeatherMap::Result::VERSION = '0.005004';
use Carp;
use strictures 2;
use JSON::MaybeXS ();
use Module::Runtime 'use_module';
use List::Objects::Types -all;
use Types::Standar
($subclass)->new(@_)
}
sub decode_json {
my (undef, $js) = @_;
JSON::MaybeXS->new(utf8 => 1)->decode( $js )
}
sub encode_json {
my (undef, $data) = @_;
JSON::MaybeXS->new(utf8 => 1)->encode(
riter => 'set_request',
isa => InstanceOf['Weather::OpenWeatherMap::Request'],
);
has json => (
required => 1,
is => 'ro',
isa => Str,
);
has data => (
lazy =>
Weather::OpenWeatherMap::Result->new_for(
$type =>
request => $my_request,
json => $http_response->content,
);
}
unless ($result->is_success) {
die Weather::Open
GV{"--TT"}.".pm");
@_ = ();
}
elsif ( $what eq "JSON" ) {
@extra = ("lib", $ARGV{"--name"}, "View", $ARGV{"--JSON"}.".pm");
@_ = ();
}
else {
@extra = (
## views triggers json and tt
if ( $ARGV{'--views'} ) {
my %map;
@map{qw/-TT --TT -JSON --JSON/} = qw/HTML HTML JSON JSON/;
for (qw/-TT --TT -JSON --JSON/) {
$
ate.tt
sub _create_JSON {
return unless my $json = $ARGV{"--JSON"};
_run_system( _creater() => "view", $json, "JSON" );
my $p = _catalyst_path( "JSON" );
my $json_code = $p->slurp;
:OpenWeatherMap::Result::Current->new(
request => $self->request,
json => $self->encode_json($_),
data => +{%$_},
)
} @list
]
},
);
sub count
003';
use Digest::SHA qw/sha256_base64/;
use File::Slurp;
use HTML::TreeBuilder;
use JSON::MaybeXS qw/encode_json/;
use NetHack::NAOdash qw/naodash_user/;
use Plack::Request;
my ($dash, $css, $css_h
sh_user \%args, $name } or return reply 500, $@;
return reply 200, encode_json($result), 'application/json' if $self->{json};
return reply 200, make_html($name, $req->query_string, $result), 'text/
r;
builder {
mount '/dash/' => App::Web::NAOdash->new->to_app;
mount '/json/' => App::Web::NAOdash->new(json => 1)->to_app;
...
}
=head1 DESCRIPTION
App::Web::NAOdash is a web inter
ava>
=head3 L<IO::Prompt::Tiny>
=head3 L<IO::Socket::INET>
=head3 L<IO::Socket::SSL>
=head3 L<JSON>
=head3 L<List::MoreUtils>
=head3 L<List::Util>
=head3 L<local::lib>
=head3 L<MetaCPAN::Clien
sub to_yaml {
require YAML;
return YAML::Dump(shift);
}
sub to_json {
require JSON;
return JSON::encode_json(shift)
}
sub from_perl {
no strict 'vars';
my $data = eval shif
hift);
}
sub from_json {
require JSON;
return JSON::decode_json(shift);
}
my %tr_functions = (
ddumper => \&to_perl,
yaml => \&to_yaml,
json => \&to_json,
);
my %i_tr_func
tions = (
ddumper => \&from_perl,
yaml => \&from_yaml,
json => \&from_json,
);
# $g = tr_hash($h, $ctl) converts hashrefs to hashrefs
# $g = tr_hash($h, $ctl, 1) does the reverse co
:
--TT Adds a C::View::TT component, defaults to HTML.pm
--JSON Adds a C::View::JSON component, defaults to JSON.pm
--dsn Specify a dsn for a model
--model Set model
ds a TT view, see --TT. Also see --views which is short for
doing both TT and JSON.
=item *
Adds a JSON view, see --JSON
=item *
Adds a HTML5 template. Currently a twitter bootstrap template from
it.
=for Euclid:
HTML.opt_default: "HTML"
=item -[-]JSON [=] [<JSON>]
Add a Catalyst::View::JSON view, defaults to YourApp::View::JSON. The
same rules and options applies as to --TT
In additi
'(1, 2, 3)'>.
=head1 SEE ALSO
L<Data::Dump::Filtered>, L<Data::Dump::Trace>, L<Data::Dumper>, L<JSON>,
L<Storable>
L<https://rt.cpan.org/Public/Bug/Display.html?id=110515>
=head1 Data::Dump AUTHOR
efault, dzil uses L<Log::Dispatchouli> which in turn uses L<String::Flogger>
which in turn uses L<JSON> to dump references, with all its limitations. This
patch improves the dumping by using L<Data::D
efault, dzil uses L<Log::Dispatchouli> which in turn uses L<String::Flogger>
which in turn uses L<JSON> to dump references, with all its limitations. This
patch improves the dumping to see data struct
t;
use warnings;
use Digest::MD5 qw/md5_hex/;
use Path::Tiny;
use File::Path qw//;
use Carp;
use JSON qw//;
use Dancer2::Plugin;
use Dancer2::Plugin::ProgressStatus::Object;
use Dancer2::Core::Respo
# We must specify the content_type and encoding here because this plugin
# only works for json, and the D2 config might have other settings
$dsl->app->add_route(
method => 'get',
status(200);
$context->response->content(JSON->new->utf8->encode($data));
$context->response->content_type('application/json');
$context->response->is_encoded(1);
.com/api/v1/access_token';
my $res = $self->agent->post($access_url => form => \%form)->res->json;
# if a problem arises, it is most likely due to given auth being incorrect
# let the us
my $captcha = $self->_do_request('POST', '/api/new_captcha', api_type => 'json');
my $captcha_id = $captcha->{json}{data}{iden};
my $url = "http://www.reddit.com/captcha/$captcha_id.png";
} = 'bearer ' . $self->access_token;
}
my $url = $self->base_url;
$url->path("$path.json");
if ($method eq 'GET') {
$url->query(%params) if %params;
return $self->ag
# changing json boolean object to perl values
sub _jsontr {
my ($self, $hash) = (@_);
foreach my $v ( values %{$hash} ) {
$v = ($v ? 'true' : 'false') if ref $v eq 'JSON::PP::Boolean
';
$self->_jsontr ( $v ) if ref $v eq 'HASH';
}
#return $hash;
}
sub _jsonjmx {
my ($self, $hook) = (@_);
if ( ref $hook eq 'HASH' ) {
$self->_jsontr ( $hook );
}
if ( ref $hook
eq 'ARRAY' ) {
foreach my $e ( @$hook ) {
$self->_jsontr ( $e );
}
}
}
# dumps output hashref
sub _print {
my ($self, %opts) = (@_);
print Dumper ( $opts{'output'} );
}
1;
__END__
nvalid tunnel $tid");
} else {
$self->client_write_line($client, "201 $tid");
my $h = $t->to_json;
$self->client_write_line($client, "$_: $h->{$_}") for
sort keys %{$h};
$self->client_w
"'tunnel show' response: $_\n";
}
$data{$k} = $v;
}
return Net::SixXS::Data::Tunnel->from_json(\%data);
}
sub debug($ $)
{
my ($self, $msg) = @_;
$self->diag->debug($msg) if $self->diag;
}
Moose;
use MooseX::Role::JSONObject::Meta::Trait;
with 'MooseX::Role::JSONObject';
has id => (
is => 'ro',
isa => 'Str',
required => 1,
traits => ['JSONAttribute'],
json_attr => 'TunnelId',
);
required => 1,
traits => ['JSONAttribute'],
json_attr => 'Password',
);
has type => (
is => 'ro',
isa => 'Str',
required => 1,
traits => ['JSONAttribute'],
json_attr => 'Type',
);
has mtu =
quired => 1,
traits => ['JSONAttribute'],
json_attr => 'Tunnel MTU',
);
has ipv6_local => (
is => 'ro',
isa => 'Str',
required => 1,
traits => ['JSONAttribute'],
json_attr => 'IPv6 Endpoint',
lar keys %$self;
require JSON;
my $j = $p ? $jp ||= JSON->new->allow_unknown->allow_blessed->utf8->convert_blessed->canonical->pretty
: $js ||= JSON->new->allow_unknown->allow_b
return join "\n", map {sprintf "%-${m1}s at %-${m2}s line %${m3}s%s", @$_} @trace;
}
sub TO_JSON { return {%{$_[0]}} }
sub classify {
my ($err, $ref) = @_;
$ref = {$ref => 1} if ! ref $
ll json error stringification to use pretty. You can also set _pretty => 1 in
individual errors, but sometimes you won't have access to the error object before
it stringifies.
=item TO_JSON
JSONifi
map { $_->{kind} eq 't1' ? $_->{data} : () }
map { @{$_->{data}{children}} } @{$res->json};
my %args = map { $_ => $self->$_ } (
qw(
username
password
k varchar not null primary key,
v jsonb
)
DONE
$s->_query(<<DONE);
create table $table\_sorted (
k varchar not null,
v jsonb not null,
score real not null,
"update redis set v = ?::jsonb where k = ?", { json => $value }, $key);
return 1 if $res->rows > 0;
$s->_query("insert into redis (k, v) values (?,?::jsonb)", $key, { json => $value } );
return
", $key)->expand;
my $json = $res->rows ? $res->hash->{v} : {};
$json->{$hkey} = $value;
$res = $s->_query("update redis set v = ?::jsonb where k = ?",{json=>$json},$key);
return 1 if