$req->respond([
200,
'OK',
{
'Content-Type' => 'application/json; charset=utf-8',
'Content-Length' => $content_length,
},
$http_body,
$keyword{ '_uploads' } = \@uploaded_files if @uploaded_files;
};
# Metadata is JSON encoded; decode_metadata lives by side effects!
if ( exists $keyword{metadata} ) {
RP
r::Logger::Entry;
use Zonemaster;
use List::MoreUtils qw[none];
use Scalar::Util qw[blessed];
use JSON::XS;
has 'entries' => (
is => 'ro',
isa => 'ArrayRef[Zonemaster::Logger::Entry]
elf->entries;
splice @$r, 0, scalar( @$r );
return;
}
sub json {
my ( $self, $min_level ) = @_;
my $json = JSON::XS->new->allow_blessed->convert_blessed->canonical;
my %numeri
{args} = $m->args if $m->args;
push @out, \%r;
}
return $json->encode( \@out );
} ## end sub json
no Moose;
__PACKAGE__->meta->make_immutable;
1;
=head1 NAME
Zonemaster::Log
[ '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 Couchbase::Bucket;
use strict;
use warnings;
use JSON::MaybeXS;
use URI;
use Storable;
use Couchbase::Core;
use Couchbase::_GlueConstants;
use Couchbase::Document;
use Couchbase::Settings;
TPDocument;
use Couchbase::N1QL::Handle;
my $_JSON = JSON::MaybeXS->new()->allow_nonref;
sub _js_encode { $_JSON->encode($_[0]) }
sub _js_decode { $_JSON->decode($_[0]) }
sub new {
my ($pkg, $co
);
$self->connect() unless $noconn;
$self->_encoder(CONVERTERS_JSON, \&_js_encode);
$self->_decoder(CONVERTERS_JSON, \&_js_decode);
$self->_encoder(CONVERTERS_STORABLE, \&Storable::fr
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
urn [
200,
[
'Content-Type' => 'application/json; charset=utf-8',
'Content-Length' => $content_length,
],
};
$keyword{ '_uploads' } = \@field_uploads if @field_uploads;
};
# Metadata is JSON encoded; decode_metadata lives by side effects!
if ( exists $keyword{metadata} ) {
RP
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
users => 'a, b, c, d',
},
],
latest_label => {
is_bad => JSON::true,
time => 1350201660000,
reasons => [
'$chargebac
as bad (or not bad).
B<Request:>
label_user('billy_jones_301', {
'$is_bad' => JSON::true,
'$reasons' => ['$chargeback'],
'$description' => 'Freeform text descri
=> '1-415-555-6040',
'$referrer_user_id' => 'janejane101',
'$changed_password' => JSON::true,
...
});
B<Response:>
{
error_message => 'OK',
status
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
istogram ();
use JSON::XS ();
# rest of implementation in C, see XS.xs and mh_axis.h
sub serialize {
my $self = shift;
my $hash = $self->_as_hash;
return JSON::XS::encode_json($hash);
}
sub d
eserialize {
my $class = shift;
my $hash = JSON::XS::decode_json(ref($_[0]) ? ${$_[0]} : $_[0]);
return $class->_from_hash($hash);
}
1;
__END__
=head1 NAME
Math::Histogram::Axis - Object
nbins + 1> for overflow.
=head2 serialize
Returns a JSON string that represents this axis object.
=head2 deserialize
Class method. Given a JSON string as generated by C<serialize()>,
recreates the
is($exptxt, $doc->value,
"Serializing/Deserializing UTF-8 characters (not bytes!) = FMT_JSON");
$doc->format('utf8');
$o->upsert($doc);
$o->get($doc);
is($exptxt, $doc->valu
ois.kisa.or.kr에서 서비스 되고 있습니다.";
my $doc = Couchbase::Document->new('utf8json', { string => $txt });
my $cb = $self->cbo;
$cb->upsert($doc);
$cb->get($doc);
is
use Moo::Role;
use Carp qw(confess);
requires '_build_content_types_provided';
requires 'encode_json';
requires 'set';
requires 'render_activemodel_response';
requires 'activemodel_type';
around '
shift @$types, { 'application/json' => 'to_json_as_activemodel' };
return $types;
};
sub to_json_as_activemodel {
my $self = shift;
return $self->encode_json( $self->render_activemodel_r
package WebAPI::DBIC::Resource::JSONAPI::Role::SetWritable;
$WebAPI::DBIC::Resource::JSONAPI::Role::SetWritable::VERSION = '0.004002';
use Devel::Dwarn;
use Carp qw(confess);
use Moo::Role;
requir
es '_build_content_types_accepted';
requires 'render_item_into_body';
requires 'decode_json';
requires 'set';
requires 'prefetch';
around '_build_content_types_accepted' => sub {
my $orig = shif
ation/vnd.api+json' => 'from_jsonapi_json' };
return $types;
};
sub from_jsonapi_json {
my $self = shift;
my $item = $self->create_resources_from_jsonapi( $self->decode_json($self->reque
!/usr/bin/perl
#词词距离计算
#输入为:
#老虎
#鲜花
#月亮
#狮子
use POSIX;
#use JSON::XS;
use Clone qw(clone);
use MongoDB;
use Smart::Comments;
use lib "/home/wyb/shell/";
#use
e;
requires '_build_content_types_accepted';
requires 'render_item_into_body';
requires 'decode_json';
requires 'set';
requires 'prefetch';
around '_build_content_types_accepted' => sub {
my $
ication/json' => 'from_activemodel_json' };
return $types;
};
sub from_activemodel_json {
my $self = shift;
my $item = $self->create_resources_from_activemodel( $self->decode_json($self-
ect;
use IO::Socket::INET;
use lib "./";
use plugin_eng;
use POE qw(Component::Server::TCP);
#use JSON::XS;
use Clone qw(clone);
use Encode;
#$tt=seg_txt("我的西瓜很大");
#print $tt."222222222
PI::DBIC::Resource::JSONAPI::Role::DBIC;
$WebAPI::DBIC::Resource::JSONAPI::Role::DBIC::VERSION = '0.004002';
use Carp qw(croak confess);
use Devel::Dwarn;
use JSON::MaybeXS qw(JSON);
use Moo::Role;
'path_for_item';
requires 'add_params_to_url';
requires 'prefetch';
requires 'type_namer';
sub jsonapi_type {
my ($self) = @_;
return $self->type_namer->type_name_for_resultset($self->set);
= $rel_info->{class}||die "panic";
my $rel_jsonapi_type = $self->type_namer->type_name_for_result_class($result_class);
my $path = $self->jsonapi_type .".". $relname;
return $path => {
:Resource::JSONAPI::Role::Item;
$WebAPI::DBIC::Resource::JSONAPI::Role::Item::VERSION = '0.004002';
use Moo::Role;
requires '_build_content_types_provided';
requires 'render_item_as_jsonapi_hash';
_json';
requires 'item';
around '_build_content_types_provided' => sub {
my $orig = shift;
my $self = shift;
my $types = $self->$orig();
unshift @$types, { 'application/vnd.api+json'
=> 'to_json_as_jsonapi' };
return $types;
};
#sub to_json_as_jsonapi { return $_[0]->encode_json($_[0]->render_item_as_jsonapi_hash($_[0]->item)) }
sub to_json_as_jsonapi {
my $self = shift;
#!/usr/bin/perl
#use Algorithm::Kmeanspp;
#use JSON::XS;
use Clone qw(clone);
#use MongoDB;
use Smart::Comments;
#use lib "/home/wuyabo/shell/";
#use Conn_mongo_jc;
use Data::Dumper;
#use IO::File