package SockJS::Transport::JSONPSend;
use strict;
use warnings;
use base 'SockJS::Transport::Base';
use JSON ();
sub new {
my $self = shift->SUPER::new(@_);
push @{$self->{allowed_methods
q 'ARRAY';
my $json = JSON->new->utf8->allow_nonref(0);
my $message;
eval { $message = $json->decode($data) } || do {
return $self->_return_error('Broken JSON encoding.');
};
:Tiny;
use JSON::MaybeXS;
use Module::Runtime qw/require_module/;
use CloudHealth::API::Error;
use CloudHealth::API::HTTPRequest;
has _json => (is => 'ro', default => sub { JSON::MaybeXS->n
(defined $body_struct) ? ('Content-Type' => 'application/json') : (),
Accept => 'application/json',
});
$req->content($self->_json->encode($body_struct)) if (defined $body_struct);
use warnings;
use base 'SockJS::Transport::Base';
use Encode ();
use IO::Compress::Deflate;
use JSON ();
use AnyEvent::Handle;
use Protocol::WebSocket::Handshake::Server;
sub new {
my $self = s
eq 'websocket') {
my $json = JSON->new->utf8->allow_nonref(0);
eval { $message = $json->decode($message) } || do {
#warn "JSON error: $@\n";
re
SockJS::Transport::XHRSend;
use strict;
use warnings;
use base 'SockJS::Transport::Base';
use JSON ();
sub new {
my $self = shift->SUPER::new(@_);
push @{$self->{allowed_methods}}, 'POST
gth $data;
my $json = JSON->new->utf8->allow_nonref(0);
my $message;
eval { $message = $json->decode($data) } || do {
return $self->_return_error('Broken JSON encoding.');
};
package WWW::FCM::HTTP::Response;
use strict;
use warnings;
use JSON qw(decode_json);
use Class::Accessor::Lite (
new => 0,
ro => [qw/http_response content is_success sent_reg_ids/],
);
use
->content;
my $req_content = decode_json($http_response->request->content);
my $sent_reg_ids = [];
if ($is_success) {
$content = decode_json $content;
if (exists $content
alize
print $mods->as_json(pretty => 1);
print $mods->as_xml;
# Deserialize
my $mods = MODS::Record->from_xml(IO::File->new('mods.xml'));
my $mods = MODS::Record->from_json(IO::File->new('mods.j
:File->new('mods.xml'), sub {
my $mods = shift;
...
});
my $count = MODS::Record->from_json(IO::File->new('mods.js'), sub {
my $mods = shift;
...
});
=head1 DESCRIPTION
This modu
$callback])
Parse an XML string or IO::Handle into a MODS::Record. This method return the parsed JSON.
If a callback function is provided then for each MODS element in the XML stream the callback wi
t, while
appropriate for some, is not what I wanted (such as the necessity of storing
fixtures in JSON files), and had a reliance on knowing the values of primary
keys, I wrote this to make it easier
::TaskUtils;
use Moose;
use TaskPipe::Task::ModuleMap;
use Try::Tiny;
use TaskPipe::RunInfo;
use JSON;
use Data::Dumper;
use Log::Log4perl;
use Module::Runtime qw(require_module);
has sm => (is => '
TaskPipe::RunInfo->new;
});
has json_encoder => (is => 'ro', isa => 'JSON', default => sub{
my $json_enc = JSON->new;
$json_enc->canonical;
return $json_enc;
});
has settings => (is =>
= $self->json_encoder->encode( $ref );
} catch {
confess "Serialize error: $_\nref was ".Dumper( $ref );
};
return $serialized;
}
sub deserialize{
my ($self,$json) = @_;
=head1 SEE ALSO
L<Catmandu::FedoraCommons>
=cut
package Catmandu::FedoraCommons::Model::purgeDatastream;
use JSON;
sub parse {
my ($class,$bytes) = @_;
return decode_json($bytes);
}
1;
mods;
if ($ENV{GATEWAY_INTERFACE} || $ENV{FCGI_ROLE}) {
@mods = ('Perinci::WebScript::JSON');
} else {
@mods = qw(Perinci::CmdLine::Any);
}
for my $i (1..@mods) {
tes the bug or desired
feature.
=head1 SEE ALSO
L<Perinci::CmdLine::Any>, L<Perinci::WebScript::JSON>
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is c
oduleMap;
use MooseX::ClassAttribute;
use TaskPipe::InterpParam;
use TaskPipe::LoggerManager;
use JSON;
use TaskPipe::ThreadManager;
use TaskPipe::Iterator_Array;
use TaskPipe::RunInfo;
use TaskPipe::
use charm;
pkg [
'nginx-full', 'php-fpm', 'php-cgi', 'php-curl', 'php-gd', 'php-json',
'php-mcrypt', 'php-readline', 'php-mbstring', 'php-xml'
],
ensure => "present",
on. Here are some strategies that
I've found over time:
=head2 Complex arguments codified as JSON
JSON is horrible for the command line because you have to escape the quotes. It's a nightmare.
c
hub.com/pplu/ARGV-Struct
=head1 THANKS
Matt S. Trout for suggesting that ARGV::Struct syntax be JSONY compatible
=head1 AUTHOR
Jose Luis Martinez
CPAN ID: JLMARTIN
CAPSiDE
jlmartin
application/json;q=0.5';
my $accept_header = HTTP::Accept->new( $header );
# returns text/html
my $use_accept = $accept_header->match( qw(text/html application/json) );
=head1
----------------+----------------------------
text/html, application/json;q=0.5 | text/html, application/json
application/json;q=0.5, text/html | text/html, application/*
application/*;q=0.5, te
der = 'text/html, application/json;q=0.5';
my $accept_header = HTTP::Accept->new( $header );
=head2 match
# header: 'text/html, application/json;q=0.5'
my $accept = $accept_head
_paths.sh',
'change_ports.sh',
'USING',
'README',
'connection.json',
'default_connection.json',
'grants.mysql',
'grants_5_7_6.mysql',
'json_in_db.sh',
'show_binlog.sh',
'show_relaylog.sh',
'add_option
fi
fi
KILL_SCRIPT
'json_in_db.sh' => <<'JSON_IN_DB_SCRIPT',
#!_BINBASH_
__LICENSE__
SBDIR="_HOME_DIR_/_SANDBOXDIR_"
cd $SBDIR
./use -e 'drop table if exists test.connection_json'
./use -e 'create t
st.connection_json(t longtext)'
./use -e '/*!50708 alter table test.connection_json modify t json */'
#./use -e "insert into test.connection_json values (load_file('$SBDIR/connection.json'))"
./use -e
TaskPipe::RunInfo->new;
});
has json_encoder => (is => 'ro', isa => 'JSON', default => sub{
my $json_enc = JSON->new;
$json_enc->canonical;
return $json_enc;
});
sub build_ua{
my
r = Log::Log4perl->get_logger;
$self->clear_cookies;
$logger->info(uc($method)." ".$self->json_encoder->encode(\@params));
my $resp = $self->ua->$method(@params);
return $resp;
}
s
sbinstr
get_json_from_dirs
get_option_file_contents
validate_json_object
fix_server_uuid
uid\n" if $DEBUG;
}
sub validate_json_object {
my ($json_filename, $json_text) = @_;
my $JSON_module = undef;
for my $module ( 'JSON', 'JSON::PP', 'JSON::XS')
{
eval "use $mo
t "# Using $module\n" if $DEBUG;
$JSON_module=$module;
last;
}
}
unless ($JSON_module)
{
print "# JSON modules not installed - skipped evaluation\n"
iny->new;
require JSON::XS;
$self->{_json} = JSON::XS->new;
require URI::Encode;
$self->{_urienc} = URI::Encode->new;
bless $self, $class;
}
sub _get_json {
my ($self, $url
) = @_;
log_trace("JSON API request: %s", $url);
my $res = $self->{_http}->get($url);
die "Can't retrieve $url: $res->{status} - $res->{reason}"
unless $res->{success};
my $d
ecoded;
eval { $decoded = $self->{_json}->decode($res->{content}) };
die "Can't decode response from $url: $@" if $@;
log_trace("JSON API response: %s", $decoded);
$decoded;
}
sub _
ec::Functions qw/catfile/;
use Data::Dumper;
use List::Util qw/min/;
use Path::Tiny;
use JSON::XS qw/encode_json/;
use Bio::Gonzales::Util::Log;
use base 'Exporter';
our ( @EXPORT, @EXPORT_OK, %EXPOR
name, \%properties);
}
sub new_from_json {
my ($class, $json) = @_;
require JSON::MaybeXS;
return $class->new(JSON::MaybeXS::decode_json($json));
}
}
1;
### main pod documentation
ce
has foo => (...);
}
my $obj = MyModel->MooseX::DataModel::new_from_json('{"version":3,"description":"a json document"}');
# $obj is just a plain old Moose object
print $obj->version;
e key passed is different from the one declared: you
get an exception. The advantage over using a JSON validator, is that after validation you still have
your original datastructure. With MooseX::Data