d $e ) {
$self->event('recv_event', $e->getType(), $e->serialize('json'));
$self->event('event_'. $e->getType(), $e->serialize('json'));
}
}
=head2 is_connected
=cut
sub is_connected {
m
epresentation of the object using only scalars, hashes, and
arrays. Some implementations support JSON serialization via dump() and
its companion method, load(); for others, dump() is only a debugging
using GD::Graph.
Args:
--key|-k|--key <keyspec> Specify keys that correlate to keys in JSON data
--option|-o option=val Specify custom command for GD::Graph
--label-x <val>
n of the same resource such as B<tucker.myplace.com/book/list> and
B<tucker.myplace.com/book/list.json> are considered as separate requests and so are
cached separately.
=head2 Cache backends
This
#!/usr/local/bin/perl
use strict;
use warnings;
use Carp;
use SVN::Class;
use FindBin;
use JSON::XS;
use Email::Stuff;
use Sys::Hostname;
my $config = {
src => Path::Class::Dir->new( $FindBin::Bi
) {
my $config_file = Path::Class::File->new( shift @ARGV );
my $supplied_conf = decode_json( $config_file->slurp );
$config = { %$config, %$supplied_conf };
}
if (!$config->{src}) {
ull
system and test summary is printed to stdout.
You may specify an alternate path to test in a JSON-formatted config file.
Use the 'src' config option to specify a path. Example:
{ 'src' : '/pat
pshot_XXX.json
|--schema_XXX.json
|--write.lock
|
|--seg_1--|
| |--segmeta.json
| |--cfmeta.json
ons]
|
|--seg_2--|
| |--segmeta.json
| |--cfmeta.json
| |--cf.dat-------|
|
the
entire index rather than to a particular segment.
=head2 snapshot_XXX.json
A "snapshot" file, e.g. C<snapshot_m7p.json>, is list of index files and
directories. Because index files, once writt
art.
Recs, or RecordStream is a collection of scripts that facilitates the parsing
of files into JSON records and the transformation of those records. Many common
UNIX programs like grep, sort, and u
eral
the tools fall into three categories: those that produce JSON records, those
that operate on JSON records, and those that convert JSON records into output.
A typical use of recs will consist of o
nd one of the third type. To begin using recs, you'll have to
decide on how to get your data into JSON. There are several scripts available
to do this, one of the most powerful of which is recs-frommu
head1 NAME
recs-fromps
=head1 recs-fromps --help-all
Usage: recs-fromps <args>
Prints out JSON records converted from the process table.
--keys <fields> Fields to output. Ma
ordStream::Operation::fromjsonarray;
our $VERSION = "4.0.25";
use strict;
use warnings;
use base qw(App::RecordStream::Operation);
use App::RecordStream::Record;
use JSON::MaybeXS;
sub init {
$this->{'EXTRA_ARGS'} = $args;
$this->{'FIELDS'} = \@fields;
$this->{'JSON'} = JSON->new();
}
sub wants_input {
return 0;
}
sub stream_done {
my ($this) = @_;
my
is, $fh) = @_;
my $json = $this->{'JSON'};
my $fields = $this->{'FIELDS'};
my $has_fields = scalar @$fields;
my $contents = do { local $/; <$fh> };
my @arrays = $json->incr_parse($content
Socket::INET;
use POSIX qw(EINTR EAGAIN EWOULDBLOCK);
use Socket qw(IPPROTO_TCP TCP_NODELAY);
use JSON::XS ();
our $CRLF = "\x0d\x0a";
our $DELIMITER = "\x20";
our $MAX_REQUEST_SIZE = 131072;
o
'request' => 1,
'request_background' => 1,
'request_multi' => 1,
);
our $JSON;
sub new_client {
my $address = shift;
my $sock = IO::Socket::INET->new(
PeerAd
ROTO_TCP, TCP_NODELAY, pack("l", 1)) or die;
$sock->autoflush(1);
$sock;
}
sub json {
$JSON ||= JSON::XS->new->allow_nonref;
}
sub support_cmd {
$CMD2NO{+shift};
}
sub make_request
::Utils::verify_buffer($buf) and last;
}
$sock->close();
return $buf ? Clutch::Utils::json->decode($buf) : undef;
}
sub request_multi {
my ($self, $args) = @_;
$self->_verify_mult
emove($sock);
$sock->close();
$res[$idx] = $buf ? Clutch::Utils::json->decode($buf) : undef;
}
}
}
wantarray ? @res : \@res;
}
package
Cl
s_string($options);
return <<USAGE;
Usage: recs-fromps <args>
__FORMAT_TEXT__
Prints out JSON records converted from the process table.
__FORMAT_TEXT__
$args_string
Default fields:
__
package App::RecordStream::Stream::Base;
use JSON qw(decode_json);
use App::RecordStream::Record;
use App::RecordStream::OutputStream;
sub new
{
my $class = shift;
my $this =
{
};
bless
$line);
}
sub accept_line
{
my $this = shift;
my $line = shift;
my $record = App::RecordStream::Record->new(decode_json($line));
return $this->accept_record($record);
}
sub finish
{
}
1;
shift;
my $options = [
['key|-k|--key <keyspec>', 'Specify keys that correlate to keys in JSON data'],
['option|-o option=val', 'Specify custom command for GD::Graph'],
['label-x <val>
pp::RecordStream::OptionalRequire::optional_use(qw(JSON decode_json));
is($loaded, 1, 'Test external module with extra args');
my $hash = decode_json('{"foo": "bar"}');
is($hash->{'foo'}, 'bar', "Tes
char json_bc[] =
"\102\103\107\110\001\020\000\000\020\000\000\000\023\004\211\214\001\124\250\210"
"\010\100\105\106\001\102\144\204\034\040\104\210\314\004\201\042\043\200\311\231"
"\040\140\144\00
$this) = @_;
return %$this;
}
sub as_hashref
{
my ($this) = @_;
return {%$this};
}
sub TO_JSON {
my ($this) = @_;
return $this->as_hashref();
}
sub has_key_spec {
my ($this, $spec) = @_
onsible for knowing the conversion from in-memory
records to record stream wire format (currently JSON).
=head1 SYNOPSIS
use App::RecordStream::OutputStream;
my $string = App::RecordStream:
warnings;
use JSON;
my $json = JSON::XS->new();
$json->allow_nonref(1);
$json->allow_blessed(1);
$json->convert_blessed(1);
sub hashref_string {
my $record = shift;
return $json->encode($recor
austed
=back
=cut
our $VERSION = "3.4";
use strict;
use warnings;
use IO::String;
use JSON qw(decode_json);
use App::RecordStream::Record;
require App::RecordStream::Operation;
my $ONE_OF = [qw
->call_next_record();
}
# Direct bless done in the name of performance
my $record = decode_json($line);
bless $record, 'App::RecordStream::Record';
return $record;
}
sub call_next_record
he::FileCache;
use Carp;
use File::Spec::Functions qw(tmpdir);
use HTTP::Request::Common;
use JSON;
use LWP::ConnCache;
use LWP::UserAgent;
use WebService::IMDB::Title;
use WebService::IMDB::Nam
ecoded_json {
my $self = shift;
my $request = shift;
my $content = $self->_response_decoded_content($request);
my $json = JSON->new();
$json->utf8(0);
my $resp = $json->deco
hift;
my $content = $self->_response_decoded_content($request);
my $json = JSON->new();
$json->utf8(0);
my $resp = $json->decode($content);
return $resp->{'copyright'};
}
1;