ch;
use strict;
use warnings;
use App::CELL qw( $CELL $log $meta $site );
use Data::Dumper;
use JSON;
use Params::Validate qw(:all);
use Try::Tiny;
# methods/attributes not defined in this module w
be AJAX calls. Their entity bodies must be valid
JSON with the following simple structure:
{ method: HTTP_METHOD, path: RESOURCE, body: BODY_JSON }
where HTTP_METHOD is any HTTP method accepted
by the REST server, RESOURCE is a
valid path to a REST server resource, and BODY_JSON is the content body to be
sent in the HTTP request to the REST server. Provided the request is properly
authorize
C<catmandu>:
catmandu convert LIDO to JSON --fix lido.fix < data/lido.xml > data/lido.json
catmandu convert JSON to LIDO --fix lido.fix < data/lido.json > data/lido.xml
See documentation of mo
ncoding of a data tree, on a single line
# using flow-style mappings and sequences
# Similar to JSON except without quoted keys
sub encode
{
my $self = shift;
my ( $args ) = @_;
if( !ref
:Parser::lido;
use Catmandu::Sane;
use Moo;
use Catmandu;
use Catmandu::Util;
use Lido::XML;
use JSON;
with 'Catmandu::Logger';
has 'lido' => (is => 'lazy');
sub _build_lido {
return Lido
igest::SHA qw/ sha1_hex sha256_hex sha384_hex sha256 hmac_sha256_base64 /;
use HTTP::Request;
use JSON;
use LWP::UserAgent;
use LWP::ConnCache;
use Net::Amazon::AWSSign;
use Time::HiRes qw/ usleep /;
->conn_cache(); } );
has json => ( isa => 'JSON', is => 'rw', default => sub { JSON->new()->canonical( 1 )->allow_nonref( 1 )->utf8( 1 ) }, trigger => sub {
shift->json->canonical( 1 )->allow_no
s_ok, $json_ref ) = $self->request( CreateTable => \%create );
# got res
if ( $res_ok && defined $json_ref->{ TableDescription } ) {
return {
status => $json_ref->{
->{title}, [] );
}
################ Page settings ################
#
# Copied from GImager.
use JSON::PP ();
# Setup fonts.
sub initfonts {
my ( $self ) = @_;
}
# API: pagesettings (inheritabl
fault} ) || {};
if ( open( my $fd, "<:utf8", $options->{pagedefs} || "pagedefs.json" ) ) {
local $/;
$ret = JSON::PP->new->utf8->relaxed->decode( scalar( <$fd> ) );
$fd->close;
}
elsif
>{pdf}->{papersize}}
}
if ( 0 ) {
open( my $fd, '>:utf8', 'pagedefs.new' );
$fd->print(JSON::PP->new->utf8->canonical->indent(4)->pretty->encode($ret));
$fd->close;
}
$self->{ps}
p::Tube>
=cut
use Moo;
use namespace::clean;
use File::Share ':all';
has json => (is => 'ro', default => sub { return dist_file('Map-Tube-Athens', 'athens-map.json') });
with 'Map::Tube';
1;
tring) and then additional
information.
Also supports output of a text summary (markdown) and/or JSON data
during operation if the $obj->filehandles array is set to include one
or more filehandle and
("Should have been good but wasn't");
}
=cut
use strict;
use CGI qw(escapeHTML);
use JSON qw(encode_json);
use base qw(Class::Accessor::Fast);
HTTP::OAIPMH::Log->mk_accessors( qw(log filehandles
}));
}
=head3 add_fh($fh,$type)
Add a filehandle to the logger. If $type is set equal to 'json' then
JSON will be written, els if 'html then HTML will be written, otherwise
text is output in markdo
file in the parent directory.
=head1 DEVELOPMENT NOTES
=head2 UTF-8
In conformance with the JSON standard, all data passing to and from the
server are assumed to be encoded in UTF-8. Users who n
C<catmandu>:
catmandu convert LIDO to JSON --fix lido.fix < data/lido.xml > data/lido.json
catmandu convert JSON to LIDO --fix lido.fix < data/lido.json > data/lido.xml
See documentation of mo
ch;
use strict;
use warnings;
use App::CELL qw( $CELL $log $meta $site );
use Data::Dumper;
use JSON;
use Params::Validate qw(:all);
# methods/attributes not defined in this module will be inherite
DALONE_MODE;
$log->debug( "Employee $nick login attempt" );
my ( $code, $message, $body_json );
if ( $standalone ) {
# check nam and pwd against MFILE_WWW_STANDALONE_CREDENTIALS_
{
$code = 200;
$message = 'OK';
$body_json = { payload =>
{
emp => { nick => $nick, ei
};
} @param_names;
my $url = $methods_urls->{$key}[0];
my $json_path = $methods_urls->{$key}[1];
my $new_method = sub {
my $self = shi
params => $extra_params });
# Only return the JSON fragment we need
return Hash::Path->get($res, split(/\./, $json_path));
};
{
# limit the scope
Clone qw( clone );
use Constant::FromGlobal DEBUG => { int => 1, default => 0, env => 1 };
use JSON::XS ();
use Moo::Role;
use Ref::Util qw(
is_arrayref
is_coderef
is_hashref
is_ref
);
has flat => (
is => 'rw',
default => sub { 0 },
lazy => 1,
);
has decode_json_substrings => (
is => 'rw',
default => sub { 0 },
lazy => 1,
);
sub all_avai
_stats {
my $self = shift;
my $c = $self->clone;
$c->stats( ['all'] );
$c->decode_json_substrings( 0 );
my @names;
$c->_looper(
$c->collect,
sub {
O exporter
=head1 SYNOPSIS
# From the commandline
$ catmandu convert JSON --fix myfixes to LIDO < /tmp/data.json
# From Perl
use Catmandu;
# Print to STDOUT
my $exporter =
tes.
=back
If you need to pass complex or structured data to your arguments you may do so using
JSON:
<prefix-name scalar='constant value'
hash={"q":"The query string"}
array=["
ion from this file
=item * when config is a text, validator will think, that it's a pure YAML or JSON and will try to parse it
=item * when config is a hashref, validator just will apply it without
g && !ref $cfg ) {
# File detected!
if ( $cfg !~ /\n/ && $cfg =~ /\.(yaml|yml|json)$/ai ) {
confess "File not found: $cfg" unless -f $cfg;
$param{config}
package Template::Lace::Components;
use Moo;
use UUID::Tiny;
use JSON::MaybeXS ();
has [qw(handlers component_info ordered_component_keys)] => (is=>'ro', required=>1);
around BUILDARGS => sub {
m
' value
}
}
sub setup_arrayrefdata_hander {
my ($class, $value) = @_;
my $ref = JSON::MaybeXS::decode_json($value);
my @array = map {
my $v = $_; $v =~s/^\$\.//;
$class->attr_value_ha
ray ];
};
}
sub setup_hashrefdata_hander {
my ($class, $value) = @_;
my $ref = JSON::MaybeXS::decode_json($value);
my %hash = map {
my $v = $ref->{$_};
$_ => $class->attr_value_handl
e_utf8 );
use File::Temp qw( tempfile );
use HTTP::Request::Common qw( GET PUT POST DELETE );
use JSON;
use LWP::UserAgent;
use Params::Validate qw(:all);
use Try::Tiny;
# methods/attributes not defi
, and generates
a "415 Unsupported Media Type" response if it is anything other than
'application/json'.
=cut
sub known_content_type {
my ( $self, $content_type ) = @_;
#$log->debug( "known
e object
if ( ref( $content_type ) eq '' ) {
return ( $content_type =~ m/application\/json/ ) ? 1 : 0;
}
if ( ref( $content_type ) eq 'HTTP::Headers::ActionPack::MediaType' ) {
validation and substitution engine
# - execute the request
# - return the proper fragment of the JSON tree
_mk_subs($methods_urls);
has '+servers' => (
default => sub { ["localhost:19888"] },
;
use strict;
use warnings;
use 5.10.0;
use Moo::Role;
use Data::Dumper;
use HTTP::Request;
use JSON::XS;
use HTML::PullParser;
use LWP::UserAgent;
use Regexp::Common qw( net );
use Scalar::Util q
=> 1,
);
has _json => (
is => 'rw',
lazy => 1,
default => sub {
return JSON::XS->new->pretty(1)->canonical(1);
},
isa => sub {
my $json = shift;
if ( ! blessed $json
|| ! $json->isa('JSON::XS')
|| ! $json->can('decode')
) {
die "Not a JSON object"
}
},
);
has debug => (
is =>