package Business::Cart::Generic::View::Order;
use strict;
use warnings;
use JSON::XS;
use Moose;
use Text::Xslate 'mark_raw';
extends 'Business::Cart::Generic::View::Base';
use namespace::autocl
ss="red">$message</span>|,
div_name => 'order_message_div',
order_count => 0,
};
return JSON::XS -> new -> utf8 -> encode($output);
} # End of cancel_order.
# -----------------------------
country_id == $$config{default_country_id})
{
$min_id = $$config{default_zone_id};
}
return JSON::XS -> new -> utf8 -> encode({menu => $self -> build_special_select($zone_map, $min_id, 'zone_id'
z;
use Moose;
use namespace::autoclean;
use LWP::UserAgent;
use DateTime;
use URI::Escape;
use JSON;
use Carp qw( croak );
use Digest::SHA qw( hmac_sha1_base64 );
use WWW::SEOmoz::URLMetric
uired';
my $res = $self->ua->get( $url );
if ( $res->is_success ) {
return from_json $res->content;
}
croak $res->content;
}
sub url_metrics {
my $self = shift;
m
ets' => sub {
return res 400 => to_json { err => 'name is required' }
unless param 'name';
# ...
return res 201 => to_json { widget => $widget };
};
dance;
ransit::Test::Example;
use strict;use warnings;
use Data::Dumper;
use IPC::Transit;
use POE;
use JSON;
use File::Slurp;
sub
import {
my $self = shift;
my ($callpack, $callfile, $callline) =
utes.json') or die "get_routes: routes.json not found\n";
my $routes;
eval {
$routes = decode_json($routes_text) or die "returned false\n";
};
die "get_routes: decode_json() fa
: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
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
use Compress::Zlib 2 qw(compress uncompress);
use Data::Stream::Bulk::Callback;
use JSON 2 qw/encode_json decode_json/;
use Metabase::Fact;
use Try::Tiny;
use Moose;
with 'Metabase::Backend::MongoD
o GUID set for fact\n";
}
my $json = compress(encode_json($fact_struct));
# g for guid; d for data
$self->coll->insert( { g => $guid, d => $json }, {safe => 1} );
return $guid;
:Cursor::slave_okay = 1;
my $obj = $self->coll->find_one( { g => $guid } );
return decode_json(uncompress($obj->{d}));
}
# DO NOT lc() GUID
sub delete {
my ( $self, $guid ) = @_;
retu
er::Logger::ConsoleAggregator::VERSION = '0.005';
}
use Dancer::Hook;
use DateTime;
use JSON qw(to_json from_json);
use Try::Tiny;
use base 'Dancer::Logger::Abstract';
# ABSTRACT: Dancer Console Log
$obj = ref $ev_res ? $ev_res : undef;
};
try {
# If its json stringified
$obj = from_json($message);
} if !$obj;
# If its just a string
push( @$strings, $m
ERR _to_json($log_message) ."\n";
}
($log_message, $strings) = ({}, []);
}
sub init {
Dancer::Hook->new( 'after', sub {
try { flush }
catch { print STDERR _to_json({ LOG_E
::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
Data::Stream::Bulk::Filter ();
use Metabase::Archive;
use Metabase::Index;
use Data::GUID ();
use JSON 2 ();
has 'archive' => (
is => 'ro',
isa => 'Metabase::Archive',
required => 1,
);
->facts ) {
push @fact_guids, $self->store( $f );
}
$fact_struct->{content} = JSON->new->ascii->encode(\@fact_guids);
}
if ( $self->archive->store( $fact_struct )
&&
rjbs, 2009-06-24
if ($class->isa('Metabase::Report')) {
my @facts;
my $content = JSON->new->ascii->decode( $fact_struct->{content} );
for my $g ( @$content ) {
# XXX no
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
se Metabase::Fact;
use Carp ();
use Data::GUID ();
use Data::Stream::Bulk::Filter 0.08;
use JSON 2 ();
use Net::Amazon::S3;
use Path::Class ();
use Compress::Zlib 2 qw(compress uncompress);
wit
n $client->$method( name => $self->bucket );
}
);
has '_json' => (
is => 'ro',
required => 1,
lazy => 1,
default => sub { JSON->new->ascii },
);
sub initialize {}
# given fact, store it
store: no GUID set for fact\n";
}
my $json = $self->_json->encode($fact_struct);
if ( $self->compressed ) {
$json = compress($json);
}
my $s3_object = $self->s3_bucket-
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
use this log module. Then you can debug like this:
debug { field1 => "data" };
debug to_json({ field2 => "data" });
debug "Raw Data";
And this module will log something like this:
$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
'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
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';
Agent;
use HTTP::Request;
use HTTP::Headers;
use vars qw(
$AUTOLOAD
$VERSION
$JSON_ENCODE
$JSON_DECODE
$DEFAULT_RETRY_MAX
$DEFAULT_RETRY_INTERVAL
);
$VERSION = sprintf "%d.%03
sub serialize_type {
return shift->{'serialize_type'} ||=
eval { require JSON } ? 'json'
: eval { require YAML::Syck } ? 'yaml'
: eval { require YAML }
a::URIEncode } ? 'uri'
: die "Can't find a module that can encode and decode (need one of JSON, YAML::Syck, YAML, Data::URIEncode, XML::Simple)";
}
###----------------------------------------
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
hex );
use English qw( -no_match_vars );
use File::Slurp qw( read_file write_file read_dir );
use JSON;
use Params::Validate qw( :all );
use Storable;
use YAML::Syck qw( LoadFile DumpFile );
=encodin
ails, it will try to use I<JSON> to load the data.
This method supports reading I<.12> and I<.13> file formats.
It can auto-detect if it was serialized with storable or JSON.
=cut
sub read_db_file {
# Data is a Storable image.
return retrieve($file_path);
}
require JSON;
return decode_json( $data );
} # }}}
1;
=back
=head1 LICENCE
Copyright 2009-2011, Bartłomiej Sygu