file extension, the value is the MIME type to send.
my %type_override = (
'json' => 'application/json; charset=UTF-8',
'htc' => 'text/x-component',
);
return ($type_overr
does not propagate to nested definitions.
=head1 CREDIT
This was inspired by the JSON Generator L<http://www.json-generator.com/>.
=head1 DEPENDENCIES
No non-core modules are required.
=head1
package Finance::Bitcoin::Feed::Site::BtcChina::Socket;
use JSON;
use Mojo::Base 'Mojo::Transaction::WebSocket';
use Scalar::Util qw(weaken);
has 'owner';
has 'ping_interval';
has 'ping_timeout';
has
$json_data = decode_json($body);
#session_id useless ?
$self->ping_interval($json_data->{pingInterval})
if $json_data->{pingInterval};
$self->ping_timeout($json_
data->{pingTimeout})
if $json_data->{pingTimeout};
$self->last_pong_at(time());
$self->last_ping_at(time());
$self->emit('setup');
}
# pong
elsif ($cod
vars{body}{result} = 'marked';
$tvars{body}{data} = join(',',@data);
$tvars{realm} = 'json';
LogDebug("body=".Dumper($tvars{body}));
}
sub Unmark {
return unless RealmCheck('p
rs{body}{result} = 'unmarked';
$tvars{body}{data} = join(',',@data);
$tvars{realm} = 'json';
# LogDebug("body=".Dumper($tvars{body}));
}
sub Marked {
return unless RealmCheck('pa
se Future;
use Future::Utils qw(repeat try_repeat);
use POSIX qw(strftime);
use JSON::MaybeXS qw(decode_json encode_json);
use MIME::Base64;
use List::Util;
use List::MoreUtils;
use B qw(svref_2object
b {
my $content = shift;
decode_json($content)->{Table};
});
}
method delete_table(TableNameType :$Table
sub {
my $content = shift;
decode_json($content)->{TableDescription}
});
}
method wait_for_table_status(Ta
nyEvent::Handle;
use Protocol::WebSocket::Handshake::Client;
use Protocol::WebSocket::Frame;
use JSON;
use URI;
use Data::Dumper;
use constant CHANNELS => qw(
order_book
live_trades
);
use
to move and rewrite into your own module.
# within these subroutines you will have access to the json response in a hash format.
sub trade {
my $self = shift;
my $data = shift;
warn Data:
while (my $msg = $self->frame->next) {
my $d;
eval { $d = $self->json->decode($msg); } or do {
my $e = $@;
warn $self->now . ' - error:
vars{body}{result} = 'marked';
$tvars{body}{data} = join(',',@data);
$tvars{realm} = 'json';
}
sub Unmark {
return unless RealmCheck('tester','admin');
$tvars{body}{success} =
rs{body}{result} = 'unmarked';
$tvars{body}{data} = join(',',@data);
$tvars{realm} = 'json';
# LogDebug("body=".Dumper($tvars{body}));
}
sub Delete {
return unless RealmCheck('t
ars{body}{result} = 'deleted';
$tvars{body}{data} = join(',',@data);
$tvars{realm} = 'json';
}
sub Dist {
return unless RealmCheck('tester','admin');
SetTester();
$cgiparam
';
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->on('json', \&on_json);
return $self;
}
sub go {
my $self = shift;
$self->SUPER::go(@_);
$self-
n(
json => sub {
my ($tx, $hash) = @_;
$self->emit('json', $hash);
});
});
return;
}
sub on_json {
my ($self, $
package Finance::Bitcoin::Feed::Site::CoinSetter::Socket;
use JSON;
use Scalar::Util qw(weaken);
use Mojo::Base 'Mojo::Transaction::WebSocket';
has 'owner';
sub configure {
my $self = shift;
my ($tx, $data) = @_;
my @packets = ('disconnect', 'connect', 'heartbeat', 'message', 'json', 'event', 'ack', 'error', 'noop');
my $regexp = qr/([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]
:102.43}]}"
elsif ($packet->{type} eq 'event') {
eval {
my $opts = decode_json($data);
$packet->{name} = $opts->{name};
$packet->{args} = $opts->{args};
package Finance::Bitcoin::Feed::Site::LakeBtc::Socket;
use JSON;
use Mojo::Base 'Mojo::Transaction::WebSocket';
use Scalar::Util qw(weaken);
has 'owner';
sub configure {
my $self = shift;
m
er);
weaken($self->{owner});
# call parse when receive text event
$self->on(
json => sub {
my ($self, $message) = @_;
$message = $message->[0];
$self->on(
'setup',
sub {
$self->send({json => ['websocket_rails.subscribe', {data => {channel => $channel}}]});
});
use strict;
use warnings;
use Data::Dumper;
use LWP::UserAgent qw();
use HTTP::Request qw();
use JSON qw();
use Class::Load qw();
use Carp qw( carp croak );
use Data::Validate::Type qw();
our $API_
;
my $json_in = JSON::encode_json( $args{'data'} );
carp "Sending JSON request >" . ( defined( $json_in ) ? $json_in : '' ) . "<"
if $verbose;
$request->content_type('application/json');
$req
uest->content( $json_in );
carp "Request object: ", Dumper( $request )
if $verbose;
my $user_agent = LWP::UserAgent->new();
my $response = $user_agent->request($request);
if (! $response->is_
azon::DynamoDB::Simple;
use Amazon::DynamoDB;
use Carp qw/cluck confess carp croak/;
use DDP;
use JSON::XS;
use Moo;
use Try::Tiny;
our $VERSION="0.01";
=head1 NAME
Amazon::DynamoDB::Simple - Simpl
oDB can't handle complex data structures. But this module
can because it serializes yer stuff to JSON if needed.
At the moment you cannot use this module against a single dynamodb server. The
table
eys %item) {
my $value = $item{$key};
$new{$key} = $self->is_valid_json($value)
? JSON::XS->new->utf8->pretty->decode($value)
: $value;
}
return %new
R) = grep(-d $_, map("$_/NNexus", @INC));
use vars qw($VERSION);
$VERSION = "2.0.3";
use Mojo::JSON 'j';
use NNexus::DB;
use NNexus::Job;
our %snapshot_credentials =
(
"dbms" => "SQLite",
"dbname
ob->execute;
my $result = $job->result;
if ($options{annotation} && ($options{annotation} eq 'json')) {j($result);}
return $result;
}
sub indexentry {
my (%options) = @_;
my $db = delete $o
json} && $conf->{json} == 1 ){
my $dest_json = $app->home->rel_file("public/${dest_lang}.json");
# Output json
$self->render_to_file('json', $dest_json
onf->{json} && $conf->{json} == 1 ){
my $dest_json = $app->home->rel_file("public/${src_lang}.json");
# Output json
$self->render_to_file('json', $dest_json, $app
onf->{json} && $conf->{json} == 1 ){
my $dest_json = $app->home->rel_file("public/${dest_lang}.json");
# Output json
$self->render_to_file('json', $de
[ 'filename=s' => 'a file from which to take the bundling information', { default => 'components.json' } ],
[ 'lib_dir=s' => 'a name for lib dir', { default => 'lib' } ],
}
sub execute {
my
o bundles
=head1 VERSION
version 0.0.10
=head1 SYNOPSIS
dzil bundle [ --filename components.json] [ --lib_dir lib ]
=head1 DESCRIPTION
This command is a very thin layer over the Dist::Zilla::P
=head2 --file
A file from which to take the bundling information. Default value is "components.json".
=head2 --lib_dir
A name for "lib" directory. Default is "lib".
=head1 AUTHOR
Nickolay Plato
JSON;
sub new {
my ($class, %args) = @_;
return bless {
%args,
cache => [],
cache_counter => 0,
}, $class;
}
sub read {
my ($self, $json) = @_;
return $self->_convert($self->_decode($json
sub _convert {
my ($self, $json) = @_;
if (ref($json) eq 'ARRAY') {
return $self->_convert($json->[1]) if $json->[0] eq "~#'";
if ($self->_cache($json->[0], $json->[0] =~ /^~#/) =~ /^~#(.+)$/
$json[1..$#$json]);
}
return $self->_convert_map($json) if $json->[0] eq "^ ";
return [map {$self->_convert($_)} @$json];
} else {
return "" if $json eq "~_";
return $json ? 1 : 0 if JSON:
ons of modules in CPAN for data access and traversal.
=over
=item *
L<Data::Diver>
=item *
L<JSON::Pointer>
=item *
L<Data::Path>
=item *
L<Data::SPath>
=item *
L<Data::DPath>
=item *
L<D
e Data::Transit::Reader::JSON;
use Data::Transit::Reader::MessagePack;
use Data::Transit::Reader::JSONVerbose;
use Data::Transit::Writer::JSON;
use Data::Transit::Writer::JSONVerbose;
use Data::Transi
use Data::Transit;
my $writer = Data::Transit::writer($fh, 'json');
$writer->write($value);
my $reader = Data::Transit::reader('json');
my $val = $reader->read($value);
For example:
use Data
it::writer($fh, 'json');
$writer->write(["abc", 12345]);
my $reader = Data::Transit::reader('json');
my $vals = $reader->read($output);
Instead of json, you may also provide json-verbose and mess
it::Writer;
use strict;
use warnings;
no warnings 'uninitialized';
our $VERSION = '0.8.04';
use JSON;
use Carp qw(confess);
sub new {
my ($class, $output, %args) = @_;
bless {
%args,
output =
owing reasons:
=over
=item *
I wanted to store my fixture tables in whatever format i wanted (JSON, YAML, Storable, etc)
=item *
I wanted to simplify the execution process to make it very transp