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:
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 Couchbase::_GlueConstants;
use Couchbase::N1QL::Params;
use JSON::MaybeXS;
use base (qw(Couchbase::View::Handle));
my $JSON = JSON::MaybeXS->new->allow_nonref;
sub new {
my ($cls, $bucket,
h %$qargs) {
$pobj->namedparam("\$$k", $JSON->encode($v));
}
} elsif (ref $qargs eq 'ARRAY') {
$pobj->posparam($JSON->encode($_)) for @$qargs;
}
while (my ($k,
urn bless $self, $cls;
}
sub process_meta {
my ($self) = @_;
eval {
$self->meta($JSON->decode($self->meta));
}; if ($@) {
return;
}
$self->_priv->{errinfo} = $sel
#!/usr/bin/env perl
use 5.14.2;
use warnings;
use JSON::XS;
my $json = JSON::XS->new->canonical->pretty->utf8;
say $json->encode($json->decode(join('',<>)));
package Net::LDNS::Packet;
use 5.10.1;
use Net::LDNS;
use MIME::Base64;
sub TO_JSON {
my ( $self ) = @_;
return {
'Net::LDNS::Packet' => {
data => encode_base64(
cessor {
accessors => [ qw(cbo) ]
};
use constant {
DESIGN_NAME => "blog"
};
my $DESIGN_JSON = {
_id => "_design/blog",
language => "javascript",
views => {
recent_posts
st(no_plan) {
my $self = shift;
my $o = $self->cbo;
my $ret = $o->design_put($DESIGN_JSON);
ok($ret->is_ok, "Design doc put did not return errors");
my $design = $o->design_get(D
ve HTTP 200");
ok($design->is_ok, "Overall object OK");
is_deeply($design->value, $DESIGN_JSON, "Got back view");
}
sub TV02_create_invalid_ddoc :Test(no_plan) {
my $self = shift;
my
package Math::Histogram;
use 5.008001;
use strict;
use warnings;
use Carp qw(croak);
use JSON::XS ();
our $VERSION = '1.04';
require XSLoader;
XSLoader::load('Math::Histogram', $VERSION);
require M
shift;
my $hash = $self->_as_hash;
return JSON::XS::encode_json($hash);
}
sub deserialize {
my $class = shift;
my $hash = JSON::XS::decode_json(ref($_[0]) ? ${$_[0]} : $_[0]);
return $clas
ins in the histogram.
=head2 serialize
Returns a JSON string that represents this histogram object.
=head2 deserialize
Class method. Given a JSON string as generated by C<serialize()>,
recreates t
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
Couchbase::_GlueConstants;
use Couchbase;
use base qw(Exporter);
our @EXPORT = (qw(COUCHBASE_FMT_JSON COUCHBASE_FMT_UTF8 COUCHBASE_FMT_RAW COUCHBASE_FMT_STORABLE));
use Class::XSAccessor::Array {
$pkg;
$rv->id($id);
$rv->value($doc);
$rv->errnum(-1);
$rv->format(COUCHBASE_FMT_JSON);
if ($options) {
while (my ($k,$v) = each %$options) {
no strict 'refs'
SE_FMT_UTF8,
raw => COUCHBASE_FMT_RAW,
storable => COUCHBASE_FMT_STORABLE,
json => COUCHBASE_FMT_JSON
);
our %FMT_NUM2STR = reverse(%FMT_STR2NUM);
sub format {
my ($self, $fmtspec) =
package Zonemaster::Logger::Entry v1.0.0;
use 5.14.2;
use Time::HiRes qw[time];
use JSON;
use Moose;
use Zonemaster;
use overload '""' => \&string;
our %numeric = (
DEBUG3 => -2,
DEBUG2
2,
WARNING => 3,
ERROR => 4,
CRITICAL => 5,
);
our $start_time = time();
my $json = JSON::XS->new->allow_blessed->convert_blessed->canonical;
has 'module' => ( is => 'ro', isa =>
uninitialized';
$argstr = join( ', ',
map { $_ . '=' . ( ref( $self->args->{$_} ) ? $json->encode( $self->args->{$_} ) : $self->args->{$_} ) }
sort keys %{ $self->args } )
i
cfg)
PREINIT:
SV *sv;
char *s;
CODE:
s = lcbvb_save_json(cfg);
if (!s) {
die("Couldn't get JSON!");
}
sv = newSV(0);
sv_usepvn(sv, s, strlen(s));
RETVA
emory");
}
if (0 != lcbvb_load_json(vbc, s)) {
const char *err = lcbvb_get_error(vbc);
lcbvb_destroy(vbc);
die("Couldn't load json: %s", err);
}
RETVAL = vbc;
Couchbase;
use Couchbase::_GlueConstants;
use URI::Escape qw(uri_escape);
use Carp qw(cluck);
use JSON::MaybeXS;
use base (qw(Couchbase::Document));
use Constant::Generate [qw(ERRINFO ROWCOUNT REQFLAG
,
rows => VHIDX_ROWBUF,
meta => VHIDX_META,
remaining_json => VHIDX_META,
http_code => VHIDX_HTCODE
};
my $JSON = JSON::MaybeXS->new->allow_nonref;
sub new {
my ($cls, $parent, $
JSON
# parser.
my $parse_whole =
$self->[VHIDX_PLPRIV]->[REQFLAGS] & LCB_CMDVIEWQUERY_F_NOROWPARSE;
foreach my $row (@$rows) {
if ($parse_whole) {
$row = $JSON
package WebService::MCBouncer;
use 5.010;
use strict;
use LWP::UserAgent;
use JSON;
use Moo;
our $VERSION = '0.03';
=head1 NAME
WebService::MCBouncer - Query MCBouncer API for Minecraft bans
=he
"Failed to query getBans for $username - " . $response->status_line;
}
my $result = JSON::from_json($response->decoded_content);
if (!$result->{success}) {
die "mcbouncer respons
"Failed to query getBans for $username - " . $response->status_line;
}
my $result = JSON::from_json($response->decoded_content);
if (!$result->{success}) {
die "mcbouncer response
g information from components.json
use Moose;
with 'Dist::Zilla::Role::FileGatherer';
with 'Dist::Zilla::Role::FileMunger';
use Dist::Zilla::File::Generated;
use JSON -support_by_pp, -no_export;
has 'filename' => (
isa => 'Str',
is => 'rw',
default => 'components.json'
);
has 'lib_dir' => (
isa => 'Str',
is => 'rw',
default => 'lib'
);
$content =~ m/(\{.*\})/s;
$content = $1;
my $json = JSON->new->relaxed->allow_singlequote->allow_barekey;
return $json->decode($content);
}
#===================================
[ '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
package Zonemaster::Config v1.0.1;
use 5.14.2;
use Moose;
use JSON;
use File::ShareDir qw[dist_dir dist_file];
use File::Slurp;
use Hash::Merge;
use File::Spec;
use Zonemaster;
has 'cfiles' => (
g_directory_list() ) {
my $cfile = File::Spec->catfile( $dir, 'config.json' );
my $new = eval { decode_json read_file $cfile };
if ( $new ) {
$config = $merger->mer
s }, $cfile;
}
my $pfile = File::Spec->catfile( $dir, 'policy.json' );
$new = eval { decode_json read_file $pfile };
if ( $new ) {
my $tc = $new->{__testca
rsion => $Module::Find::VERSION } );
info( DEPENDENCY_VERSION => { name => 'JSON', version => $JSON::VERSION } );
info( DEPENDENCY_VERSION => { name => 'File::ShareDir',
e Zonemaster::Recursor;
use Net::LDNS;
use Net::IP::XS qw(:PROC);
use Time::HiRes qw[time];
use JSON::XS;
use MIME::Base64;
use Module::Find qw[useall];
use Carp;
use List::Util qw[max min sum];
us
rn $self->string cmp $other->string;
}
sub save {
my ( $class, $filename ) = @_;
my $json = JSON::XS->new->allow_blessed->convert_blessed;
open my $fh, '>', $filename or die "Cache save
foreach my $addr ( keys %{ $object_cache{$name} } ) {
say $fh "$name $addr " . $json->encode( $object_cache{$name}{$addr}->cache->data );
}
}
close $fh or die $!;
t->fld = NULL; }
_free_cv(cv_serialize); _free_cv(cv_deserialize);
_free_cv(cv_jsonenc); _free_cv(cv_jsondec);
_free_cv(cv_customenc); _free_cv(cv_customdec);
#undef _free_cv
}
/*Cons
ct->cv_customdec;
} else if (type == PLCB_CONVERTERS_JSON) {
*cv_encode = &object->cv_jsonenc;
*cv_decode = &object->cv_jsondec;
} else if (type == PLCB_CONVERTERS_STORABLE) {
e("Client does not have a config yet");
}
tmpstr = lcbvb_save_json(orig);
if (!tmpstr) {
die("Couldn't get JSON dump");
}
cp = lcbvb_create();
if (!cp) {
free(t
my $json = $c->stash('json');
unless ( defined $json->{data} ) {
$json->{data} = {};
$c->stash( 'json' => $json );
=head1 MOJOLICIOUS HOOKS
This module installs an before_render application hook, which gurantees JSON output.
Refer L<Mojolicious::Controller::REST> documentation for output format.
Hook installati