'order_message_div',
content => $self -> templater -> render('error.tx', $param),
};
return JSON::XS -> new -> utf8 -> encode($output);
} # End of format_errors.
# ----------------------------
> 'order_message_div',
content => $self -> templater -> render('note.tx', $param),
};
return JSON::XS -> new -> utf8 -> encode($output);
} # End of format_note.
# ------------------------------
ns a JSON and utf8 encoded block of text (usually of error messages) suitable for sending to the client.
=head2 format_note($note)
$note is a hashref of information for the user.
Returns a JSON and
rnings;
use strict;
# our required modules
use LWP::UserAgent;
use URI::Escape;
use Encode;
use JSON;
use Carp;
# just for debugging the module
# use Data::Dumper;
# use Devel::Peek;
use constant
=item * retries = Integer value; The number of retries to send an API request if an http error or JSON decoding error occurs. Defaults to 0 (try only once - don't retry). If max_retries is set to 4, a
nteger value in seconds; The amount of time to wait before retrying a request if an HTTP error or JSON decoding error occurs.
=item * max_lag = Integer value in seconds; Wikipedia runs on a database
t;
my @candidates = $self->opt->get_file
? ($self->opt->get_file)
: qw/MYMETA.json MYMETA.yml META.json META.yml/;
for my $f ( @candidates ) {
next unless -r $f;
my $mymeta = eval
package Business::Cart::Generic::View::Search;
use strict;
use warnings;
use JSON::XS;
use Moose;
extends 'Business::Cart::Generic::View::Base';
use namespace::autoclean;
our $VERSION = '0.85';
package Google::GeoCoder::Smart;
require Exporter;
use LWP::Simple qw(!head);
use JSON;
our @ISA = qw(Exporter);
our @EXPORT = qw(geocode parse);
our $VERSION = 1.16;
=head1 NAME
Smart - Goo
ing.
This module only depends on LWP::Simple and JSON.
This version removes the depriciated homemade xml parsing and goes completely with the JSON format.
If you need the old xml version, the ol
}{lng};
It is helpful to know the format of the json returns of the api.
A good example can be found at http://www.google.com/maps/apis/geocode/json?address=1600+Amphitheatre+Parkway+Mountain+View,
package Business::Cart::Generic::View::Product;
use strict;
use warnings;
use JSON::XS;
use Moose;
use Text::Xslate 'mark_raw';
extends 'Business::Cart::Generic::View::Base';
use namespace::auto
lk::Array;
use Fcntl ':flock';
use IO::File ();
use List::AllUtils qw/any all/;
use JSON 2 qw/encode_json decode_json/;
use Regexp::SQL::LIKE 0.001 qw/to_regexp/;
use Tie::File;
use MooseX::Types::Pat
" ) unless $fact->guid;
my $metadata = $self->clone_metadata( $fact );
my $line = encode_json($metadata);
my $filename = $self->index_file;
my $fh = IO::File->new( $filename, "a+" )
flock $fh, LOCK_SH;
{
while ( my $line = <$fh> ) {
my $parsed = decode_json($line);
push @matches, $parsed if $query->{-where}->($parsed);
}
}
$f
$data_dir->mkpath or die "coudln't make path to $data_dir";
my $index = $data_dir->file('index.json');
$index->touch;
my $archive = $data_dir->file('archive.sqlite');
return Metabase::Libra
ets' => sub {
return res 400 => to_json { err => 'name is required' }
unless param 'name';
# ...
return res 201 => to_json { widget => $widget };
};
dance;
" Inserts raw data as the value of the specified key.",
" Note that <data> is usually JSON.",
],
putref => [
"putref <key> <perl data>",
" Inserts a serialized Perl d
{
print $o "Usage: getref <key>\n";
return
}
my $ser = Bot::Cobalt::Serializer->new('JSON');
unless ( $db->dbopen(ro => 1) ) {
print $o "Database open failure\n";
return
}
f;
eval { $ref = $ser->thaw($item) };
if ($@) {
print $o "Could not thaw value; maybe not JSON?\n";
return
}
unless (ref $ref) {
print $o "Thawed value not a reference\n";
r
gin::Server::JSONRPC::Batch;
use strict;
use warnings;
use Class::Load ();
use HTTP::Body ();
our $VERSION = '0.02';
our $Method = 'system.handle_batch';
BEGIN {
my $class = 'JSON::RPC::Common
q 'ARRAY') {
return $class->new_from_data(
jsonrpc => '2.0',
id => scalar(time()),
method => $Catalyst::Plugin::Server::JSONRPC::Batch::Method,
params => $args[0]
);
up_engine {
my $app = shift();
$app->server->jsonrpc->add_private_method(
$Method => sub {
my ($c, @args) = @_;
my $config = $c->server->jsonrpc->config;
my $req = $c->req;
my $re
::Fact;
use Carp ();
use Data::Stream::Bulk::Callback;
use Data::GUID ();
use File::Slurp ();
use JSON 2 ();
use MooseX::Types::Path::Class;
with 'Metabase::Archive';
has 'root_dir' => (
is => '
File::Slurp::write_file(
$self->_guid_path( $guid ),
{binmode => ':raw'},
JSON->new->ascii->encode($fact_struct),
);
return $guid;
}
# given guid, retrieve it and ret
($guid) );
}
sub _extract_file {
my ($self, $file) = @_;
# read the fact
my $fact_struct = JSON->new->ascii->decode(
File::Slurp::read_file( $file, { binmode => ':raw' } ),
);
return $f
:Bulk::Array;
use Data::Stream::Bulk::DBI;
use Data::Stream::Bulk::Filter;
use File::Temp ();
use JSON 2 ();
use List::AllUtils qw/uniq/;
use Metabase::Fact;
use SQL::Abstract;
use SQL::Translato
,
};
my $json = eval { JSON->new->utf8->encode($fact) };
Carp::confess "Couldn't convert to JSON: $@"
unless $json;
# if ( $self->compressed ) {
# $json = compress($json);
# }
tr
f->dbis->insert($self->_table_name, {
guid => $self->_munge_guid($guid),
fact => $json,
});
$self->dbis->commit;
}
catch {
$self->dbis->rollback;
Carp::confess("E
to whatever you set your config->data_connections->session->cookie_domain to
in your asp4-config.json. Otherwise defaults to C<$ENV{HTTP_HOST}>.
You can override the defaults by passing in a domain
gNode::Web;
use strict;
use warnings 'all';
use base 'ASP4::ConfigNode';
use Carp 'confess';
use JSON::XS;
sub new
{
my $class = shift;
my $s = $class->SUPER::new( @_ );
$s->{handler_resol
ding: $!";
local $/;
my $json = eval { decode_json( scalar(<$ifh>) ) }
or confess "Error parsing '$item->{include_routes}': $@";
ref($json) eq 'ARRAY'
or confess "Fil
e '$item->{include_routes}' should be an arrayref but it's a '@{[ ref($json) ]}' instead.";
@$json;
} : $_
} @original;
my $router = Router::Generic->new();
map { $router->add_route
se;
use namespace::autoclean;
use Moose::Util::TypeConstraints;
coerce 'Bool', from class_type('JSON::XS::Boolean'), via { $_ ? 1 : 0 };
has id => (
isa => 'Int',
is => 'ro',
required =
g',
png => 'image/png',
bmp => 'image/bmp',
gif => 'image/gif',
json => 'application/x-json',
css => 'text/css',
pdf => 'application/x-pdf',
js => 'text/javas
$conn->password
);
}# end foreach()
=head1 JSON Config File
ASP4::ASP keeps all of its configuration inside of C</conf/asp4-config.json>
Here is an example:
{
"system": {
"po
d1 NAME
ASP4::ErrorHandler - Default fatal error handler
=head1 SYNOPSIS
In your C<asp4-config.json>:
...
"errors": {
"error_handler": "ASP4::ErrorHandler",
"mail_errors_to":
rict;
use warnings 'all';
use Carp 'confess';
use ASP4::ConfigFinder;
use ASP4::ConfigParser;
use JSON::XS;
our $Configs = { };
#====================================================================
$ifh, '<', $path
or die "Cannot open '$path' for reading: $!";
local $/;
my $doc = decode_json( scalar(<$ifh>) );
close($ifh);
(my $where = $path) =~ s/\/conf\/[^\/]+$//;
$Configs->{$
hed on a per-path basis. Paths are full - i.e. C</usr/local/projects/mysite.com/conf/asp4-config.json> -
so there should never be a clash between two different configurations on the
same web server,