#!/usr/bin/env perl
my $app = qx{which read_json};
chomp $app;
require $app;
use Data::Float qw/float_is_infinite float_is_nan/;
use Scalar::Util qw/looks_like_number/;
use JSON;
use Switch;
our @EXPORT_OK = qw(convert get_units);
our $VERSION = '0.0322';
our $DE
'NO_DATA_FILE' ) {
$units = encode_json( old_get_units() );
}
else {
$units = read_file($data_file);
}
return decode_json($units);
}
# does it make sense to return
tly only supports JSON) - then you will be able to use C::P as a service. See examples/service.pl
for an example Dancer2 script. See data/units.json for an example of a valid json data set.
See t
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
th0;
use 5.010;
use parent 'Doorman::PlackMiddleware';
use strict;
use LWP::UserAgent;
use JSON qw/decode_json/;
use namespace::autoclean;
our $VERSION = "0.01";
our $AUTHORITY = "https://recollect
($resp->is_success) {
my $data = eval { decode_json($resp->content) } || {};
if ($@) {
warn "Auth0: Got invalid JSON in Auth exchange: "
. "code=$code stat
($resp->is_success) {
my $data = eval { decode_json($resp->content) } || {};
if ($@) {
warn "Auth0: Got invalid JSON in /userinfo: "
. "token=$access_token
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);
my ($captcha_id, $captcha_text) = $self->_solve_captcha();
my %form = (
api_type => 'json',
captcha => $captcha_text,
iden => $captcha_id,
subject => 'subjec
my %tunnels = (
T00001 => Net::SixXS::Data::Tunnel->from_json(\%data1),
T00002 => Net::SixXS::Data::Tunnel->from_json(\%data2),
);
my $s = Net::SixXS::Server::AnyEvent->new(usernam
.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
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
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;
k?
my $cb = ref $_[-1] eq 'CODE' ? pop : undef;
$res->$cb if $cb;
my @mods = @{$res->json->{data}{children}};
# FIXME should we return User objects instead? or combined?
my @coll
my $pkg = 'Mojo::Snoo::Subreddit::About::' . $self->name;
$self->_monkey_patch($pkg, $res->json->{data});
}
sub _toggle_subscribe {
my ($self, $action) = @_;
# Calling $self->about fe
ams->{title} //= $title // '';
$params->{sr} = $self->name;
$params->{api_type} = 'json';
$params->{kind} = $kind;
my $res = $self->_do_request('POST', '/api/submit', %$par
'(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
map { $_->{kind} eq 't1' ? $_->{data} : () }
map { @{$_->{data}{children}} } @{$res->json};
my %args = map { $_ => $self->$_ } (
qw(
username
password
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
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',
:
--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
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
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
my %tunnels = (
T00001 => Net::SixXS::Data::Tunnel->from_json(\%data1),
T00002 => Net::SixXS::Data::Tunnel->from_json(\%data2),
);
my $s = Net::SixXS::Server::Inetd->new(username =
"'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;
}