$json = $self->http_post(gen_url($api,@query_string),("Content-Type"=>"application/json; charset=UTF-8"),Content=>$self->json_encode($post));
return unless defined $json;
my $d = $self->json_
decode($json);
return unless defined $d;
return if $d->{BaseResponse}{Ret}!=0;
return if $d->{Count}==0;
my %member_info;
my @member_key = qw(HeadImgUrl NickName PYInitial PYQuanP
::Log::LogDispatch> this can be thought of as a common logging interface.
package MyApp::View::JSON;
extends 'MyApp::View';
with 'MooseX:Log::Log4perl';
sub bar {
$self->logger->info("E
warnings;
use HTML::TreeBuilder::LibXML;
use Hash::MultiValue;
use Scalar::Util qw(refaddr);
use JSON;
use URI;
our $VERSION = '0.05';
sub new {
my ($class, %args) = @_;
bless {
items => [],
= @_;
my $self = $class->new(%opts);
$self->_parse($content);
$self
}
sub as_json {
my ($self) = @_;
encode_json +{
items => $self->{items},
};
}
sub items {
my ($self) = @_;
$self->{item
my $json = $microdata->as_json;
use Data::Dumper;
warn Dumper $microdata->items; # returns top level items
=head1 DESCRIPTION
HTML::Microdata is extractor of microdata from HTML to JSON etc.
t;
use Moo;
use MooX::late;
use MooX::ChainedAttributes;
use HTTP::Thin;
use JSON::Any;
use Try::Tiny;
use Scalar::Util qw/weaken/;
use Carp qw(confess);
use cons
s_json {
my $self = shift;
my $request = $self->request;
$request->header(
'Accept' => 'application/json',
'Content-Type' => 'application/json',
);
if ( my $data = shift ) {
$request->content( JSON::Any->encode($data) );
}
weaken($self);
$self->decoder(
sub {
my
$json = $self->http_post(gen_url($api,@query_string),("Content-Type"=>"application/json; charset=UTF-8"),Content=>$self->json_encode($post));
return unless defined $json;
my $d = $self->json_
decode($json);
return unless defined $d;
return if $d->{BaseResponse}{Ret}!=0;
my @member_key = qw(HeadImgUrl NickName PYInitial PYQuanPin Alias Province City Sex Id Uin Signature DisplayN
package Google::reCAPTCHA;
use strict;
use warnings;
use Carp;
use LWP::UserAgent;
use JSON qw( decode_json );
use Params::Validate qw( validate SCALAR );
our $VERSION = '0.06';
use constant URL =
ponse = $ua->post( URL , $pd );
if ( $response->is_success) {
my $data = decode_json( $response->decoded_content );
if ( exists ( $data->{'error-codes'} ) ) {
seX::AttributeShortcuts;
use Types::Standard qw/Str Bool/;
use Types::URI qw/Uri/;
use JSON::MaybeXS 'decode_json';
use Path::Tiny;
with 'Badge::Depot';
our $VERSION = '0.0103'; # VERSION
# ABSTRACT:
$self = shift;
return 'unknown' if !path('META.json')->exists;
my $json = path('META.json')->slurp_utf8;
my $data = decode_json($json);
return 'unknown' if !exists $data->{'prereqs
META.json> and uses that.
It is set to 'unknown' if it is neither given or exists in C<META.json>.
=head2 trailing
A string to add after the version, if the version is fetched from C<META.json>. De
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
ce::autoclean;
use Bio::Community::Member;
use Bio::Community::TaxonomyUtils;
use JSON::XS qw( decode_json encode_json );
use DateTime;
use constant BIOM_NAME => 'Biological Observation Matrix
);
has '_json' => (
is => 'rw',
#isa => 'JSON::XS',
required => 0,
init_arg => undef,
default => undef,
lazy => 1,
predicate => '_has_json',
reader => '_get_json',
writer
lf->_get_max_col) {
$name = $self->_get_json->{'columns'}->[$col-1]->{'id'};
}
$self->_set_col( $col );
return $name;
}
method _parse_json () {
# Retrieve all text content
my $s
use JSON::PP qw(encode_json decode_json);
use Moo::Role;
requires 'inflate';
requires 'deflate';
has encoder_json => (is => 'lazy');
has decoder_json => (is => 'lazy');
sub _build_encoder_json {
ow_nonref(1)->convert_blessed(1);
}
sub _build_decoder_json {
my $self = shift;
weaken($self);
JSON::PP->new->allow_nonref(1)->filter_json_single_key_object(
__proxied_object__ => sub { $se
ERSAL::TO_JSON = sub { $self->deflate($_[0]) };
decode_json($self->encoder_json->encode($data));
}
sub decode_objects {
my ($self, $data) = @_;
$self->decoder_json->decode(encode_json($data));
#!/usr/bin/env perl
my $app = qx{which read_json};
chomp $app;
require $app;
l loads content into the Plack::Response object
if ($self->res->content_type ne "application/json") { # already UTF8 encoded
my $content = $self->res->content;
my $bytes = encode(
nd_json' => sub {
my $orig = shift;
my $self = shift;
my $data = shift;
my $enc = $conf->get( 'server.encoding.response' => undef );
try {
# calls JSON::XS::encode_json($
if ($self->aborted($err)) { # expected
$self->res->content_type("application/json; charset=$enc") if $enc; # it's already set, but without charset
$err->rethrow;
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
pe_charset, undef, 'Got correct content-type charset');
# std config, json content
my $expected_from_json = {
foo => 'bar',
baz => [qw(barp beep)],
0.1:9999/json");
#warn $mech->content;
# see comments in UTF8.pm for why I can't use cmp_deeply
#cmp_deeply(JSON->new->utf8->decode($mech->content), $expected_from_json, 'Decod
ected data from JSON'); # fails '�' - that's what is in the content
#cmp_deeply(JSON->new->decode($mech->content), $expected_from_json, 'Decoded expected data from JSON'); # fa
package Tak::JSONChannel;
use JSON::PP qw(encode_json decode_json);
use IO::Handle;
use Scalar::Util qw(weaken);
use Log::Contextual qw(:log);
use Moo;
has read_fh => (is => 'ro', required => 1);
ha
ine {
my ($self, $line) = @_;
my $data = eval { decode_json($line) };
unless ($data) {
$self->write_message(mistake => invalid_json => $@||'No data and no exception');
return;
}
unle
b write_message {
my ($self, @msg) = @_;
my $json = eval { encode_json(\@msg) };
unless ($json) {
$self->_raw_write_message(
encode_json(
[ failure => invalid_message => $@||'N
_for_tests('dies')), poet => $poet);
$self->add_comp(path => '/json.mc', src => encode('UTF-8', $self->content_for_tests('json')), poet => $poet);
}
sub content_for_tests {
my ($self, $wan
ING UNESCAPED: <% uri_unescape(\$m->req->query_string) %>
ASCII
my $src_json = <<SRC;
<\%init>
my \$data_for_json = {
foo => 'bar',
baz => [qw(barp beep)],
9 => { one
\$data_for_json);
SRC
return $src_utf8 if $want eq 'utf8';
return $src_plain if $want eq 'plain';
return $src_utf8_dies if $want eq 'dies';
return $src_json if
mer> - brilliant. beautiful. insane. extensive. excessive. try it.
L<JSON::XS> - no, really. If it's just plain data, JSON is a great option.
=head1 AUTHOR
mst - Matt S. Trout <mst@shad
ore details.
EXPORTER_DECLARE_SPECS
$fatpacked{"JSON/PP.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'JSON_PP';
package JSON::PP;
# JSON-2.0
use 5.005;
use strict;
use base qw(
se Carp ();
use B ();
#use Devel::Peek;
$JSON::PP::VERSION = '2.27203';
@JSON::PP::EXPORT = qw(encode_json decode_json from_json to_json);
# instead of hash-access, i tried index-ac
e charset');
# utf8 config, json content
$mech->get_ok("http://127.0.0.1:9999/json");
#warn $mech->content;
my $expected_from_json = {
foo => 'bar',
_deeply(JSON->new->utf8->decode($mech->content), $expected_from_json, 'Decoded and de-JSONified expected data from JSON');
# this doesn't work
#my $expected_mangled_from_json = {%$e
xpected_from_json, heart => '�'}; # �
# I can't figure out how to get this test to work. The cmp_deeply fails if fed
# the unmangled hashref as expected, I
#
package Shadowd::Connector;
use 5.010;
use strict;
use JSON;
use Config::IniFiles;
use IO::Socket;
use IO::Socket::SSL;
use Crypt::Mac::HMAC qw(hmac_hex);
use Attribute::Abstract;
use POSIX qw(strft
STATUS_BAD_REQUEST => 2,
STATUS_BAD_SIGNATURE => 3,
STATUS_BAD_JSON => 4,
STATUS_ATTACK => 5,
STATUS_CRITICAL_ATTACK
' . $!);
binmode $handler;
my $content = <$handler>;
my $json = decode_json($content);
foreach my $entry (@$json) {
if (!defined $entry->{'path'} && defined $entry->{'caller'
nt' ? 'current.json'
: $type =~ /^3day/ ? '3day.json'
: $type eq 'forecast' ? '3day.json'
: $type eq 'hourly' ? 'hourly.json'
: $type eq 'failure' ? 'failure.json'
: $type e
q 'error' ? 'failure.json'
: $type eq 'find' ? 'find.json'
: $type eq 'search' ? 'find.json'
: confess "Unknown type $type"
);
path($path)->slurp_utf8
}
{ package
Weather
ecast_json} )
: HTTP::Response->new( 200 => undef => [] => $self->{hourly_json} )
} elsif ($url =~ /find/) {
return HTTP::Response->new( 200 => undef => [] => $self->{find_json} )