::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
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
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
idator::VERSION = '0.24';
use HTML::FormHandler::Moose::Role;
use Method::Signatures::Simple;
use JSON ();
has_field _validation_scripts => (type => 'JavaScript', set_js_code => '_js_code_for_valida
n_types => (is => 'rw', isa => 'ArrayRef', default => sub { [ qw(Submit Hidden noCAPTCHA Display JSON JavaScript) ] });
has skip_all_remote_validation => (is => 'rw', isa => 'Bool', default => 0);
>skip_all_remote_validation;
my $spec_data = $self->_data_for_validation_spec;
my $spec = JSON->new->utf8
->allow_nonref
->pretty(1)
N::Converter;
use 5.006;
use strict;
use warnings;
use Encode;
use Spreadsheet::ParseExcel;
use JSON::XS;
use IO::All -utf8;
use Carp;
=head1 NAME
HON::I18N::Converter - perl I18N Converter
=head
ncodage
my $encoder = JSON::XS->new->ascii->pretty->allow_nonref;
#Parcours d'une table de hachage
foreach my $lang ( keys %{ $self->labels } ) {
my $json = $encoder->encode( { str
self->labels->{$lang} } );
#Intitule de chaque section
$content .= "\$.i18n.$lang = $json;\n";
}
#Derniere ligne du document jQuery
$content .= '})(jQuery);';
$content >
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
_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
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
#
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;
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
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
Weather::OpenWeatherMap::Result->new_for(
$type =>
request => $my_request,
json => $http_response->content,
);
}
unless ($result->is_success) {
die Weather::Open
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));
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
: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 =>
:OpenWeatherMap::Result::Current->new(
request => $self->request,
json => $self->encode_json($_),
data => +{%$_},
)
} @list
]
},
);
sub count
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} )
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'} ) ) {
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'