enu::ToJSON;
use 5.008;
use strict;
use warnings FATAL => 'all';
use Carp;
use parent 'HTML::Widgets::NavMenu::Object';
use JSON qw(encode_json);
=head1 NAME
HTML::Widgets::NavMenu::ToJSON - con
idgets::NavMenu to JSON
=head1 VERSION
Version 0.0.1
=cut
our $VERSION = '0.0.1';
=head1 SYNOPSIS
use HTML::Widgets::NavMenu::ToJSON;
use HTML::Widgets::NavMenu::ToJSON::Data_Persistence
avMenu::ToJSON::Data_Persistence::YAML->new(
{
filename => '/path/to/persistence_data.yaml',
}
);
my $obj = HTML::Widgets::NavMenu::ToJSON->new(
PTION
This app will fork a ruby process that can handle rack requests.
Requests are converted to JSON and sent over a unix socket as a
netstring, a response is then read and used as the psgi response
=> '无',
rule => [],
},
]);
$c->render( json => {
result => 'false',
messages => $result->errors
}) if $result
Merge qw/merge/;
use Data::Dumper;
use Carp qw( croak );
use base qw( Exporter );
use JSON::MaybeXS qw( encode_json );
use Clustericious::Config;
# ABSTRACT: Helpers for clustericious config files.
o
r @mergeStack;
our @EXPORT = qw( extends_config get_password home file dir hostname hostname_full json yaml address public_address interface );
sub extends_config
{
my($name, @args) = @_;
push @
;
}
sub hostname_full
{
require Sys::Hostname;
Sys::Hostname::hostname();
}
sub json ($)
{
encode_json($_[0]);
}
sub yaml ($)
{
require YAML::XS;
local $YAML::UseHeader = 0;
my $str
package Plack::App::Prack::Response;
use strict;
use warnings;
use JSON;
sub new {
my ($class, $sock) = @_;
die "socket is required" unless $sock;
my $self = bless { sock => $sock }, $class
de_json $self->read_ns;
$self->{body} = [];
while (my $chunk = $self->read_ns) {
push @{$self->{body}}, $chunk;
}
$self->{sock}->shutdown(0);
}
sub handle_error {
my ($self, $json)
= @_;
my $stack = decode_json $json;
die join "\n", map {$stack->{$_}} qw/name message stack/;
}
sub headers {
my $self = shift;
if ($self->{headers}) {
return [ %{$self->{headers}} ];
alled" } = $sub };
$sub->($self);
}
package Clustericious::Config::Callback;
use JSON::MaybeXS qw( encode_json );
sub new
{
my($class, @args) = @_;
bless [@args], $class;
}
sub args { @{ sh
sub execute { '' }
sub to_yaml
{
my($self) = @_;
"!!perl/array:@{[ ref $self ]} @{[ encode_json [@$self] ]}";
}
package Clustericious::Config::Callback::Password;
use base qw( Clustericious::
=head1 DESCRIPTION
Clustericious::Config reads configuration files which are Mojo::Template's
of JSON or YAML files. There should generally be an entry for
'url', which may be used by either a clien
package Plack::App::Prack::Request;
use strict;
use warnings;
use JSON;
use Plack::App::Prack::Response;
my @ENV_KEYS = qw/REQUEST_METHOD PATH_INFO QUERY_STRING
SERVER_NAME SERVE
ift;
return length($data).":".$data.",";
}
sub write {
my $self = shift;
my $env = encode_json($self->_filter_env($self->{env}));
my $input = "";
my $buf = "";
while ($self->{env}->{'p
ck::App::Prack::Worker;
use strict;
use warnings;
use Time::HiRes;
use File::Temp ':POSIX';
use JSON;
use IO::Socket::UNIX;
use Plack::App::Prack::Request;
my $NACK = 'Nack::Server.run(ARGV[0], :fi
= $sock->getline;
# could be a stack trace
if ($p !~ /^\d+$/) {
my $stack = decode_json $p;
die "$stack->{name}: $stack->{message}";
}
$self->{sock} = $sock;
$self->{
ute;
use MojoX::Log::Log4perl;
use Log::Log4perl qw/:easy/;
use File::Temp;
use JSON::MaybeXS qw( encode_json decode_json );
use Carp qw( carp );
use Mojo::Util qw( monkey_patch );
# ABSTRACT: Constr
$meta && $meta->get("skip_existing");
$body = encode_json $arg;
$headers = { 'Content-Type' => 'application/json' };
} elsif (ref $arg eq 'CODE') {
$cb = $s
||= 'application/json';
if($body && ref $body eq 'HASH' || ref $body eq 'ARRAY')
{
$headers->{'Content-Type'} = 'application/json';
$body = encode_json $body;
}
r
ocalhost:1234' }];
YAML:
create_config_ok 'Foo', <<EOF;
---
url: http://localhost:1234
EOF
JSON:
create_config_ok 'Foo', <<EOF;
{"url":"http://localhost:1234"}
EOF
In addition to being a t
:Riak::Fast::MapReduce::Phase::Map;
use Data::Riak::Fast::MapReduce::Phase::Reduce;
use JSON::XS qw/encode_json/;
with 'Data::Riak::Fast::Role::HasRiak';
=head1 DESCRIPTION
A map/reduce query.
=h
riak->send_request({
content_type => 'application/json',
method => 'POST',
uri => 'mapred',
data => encode_json({
inputs => $self->inputs,
query
package Data::Riak::Fast::MapReduce::Phase::Link;
use Mouse;
use JSON::XS ();
# ABSTRACT: Link phase of a MapReduce
with ('Data::Riak::Fast::MapReduce::Phase');
=head1 DESCRIPTION
A map/reduce li
sub pack {
my $self = shift;
my $href = {};
$href->{keep} = $self->keep ? JSON::XS::true() : JSON::XS::false() if $self->has_keep;
$href->{bucket} = $self->bucket if $self->has_buck
();
use constant NAME => 'OMDB';
use constant PLOT => 'short';
use constant RESPONSE => 'json';
sub new {
my $class = shift;
my $args = shift;
my $self = $class->SUPER::new($ar
package Data::Riak::Fast;
use Mouse;
use JSON::XS qw/decode_json/;
use URI;
use Data::Riak::Fast::Result;
use Data::Riak::Fast::ResultSet;
use Data::Riak::Fast::Bucket;
use Data::Riak::Fast::MapRed
@parts
],
}
);
}
sub _buckets {
my $self = shift;
return decode_json(
$self->send_request({
method => 'GET',
uri => '/buckets',
,
uri => $request_str
});
}
sub stats {
my $self = shift;
return decode_json(
$self->send_request({
method => 'GET',
uri => '/stats',
all other operators will be derived from '""'
;
# be treated like an plain array by JSON::to_json()
sub TO_JSON {my $self = shift; return [@$self]}
# additional methods for Template Toolkit, if p
EACH %]
=head2 Interaction with JSON
Likewise, L<JSON/to_json> only exports objects who possess a C<TO_JSON()>
method; so such a method is also implemented here. JSON is really
reluctant to emit any
additional calls are
needed to make it work :
my $converter = JSON->new->allow_blessed->convert_blessed;
print $converter->to_json($schizophrenic); # ["FOO","BAR","BUZ"]
=head1 PUBLIC METHODS
.h"
#include <usdt.h>
typedef enum {
none = 0,
integer,
string,
json
} perl_argtype_t;
STATIC MGVTBL probe_vtbl = { 0, 0, 0, 0, 0, 0, 0, 0 };
STATIC MGVTBL provider_
h: should be string");
return (void *) ret;
}
static void *
json_argument(SV *obj)
{
int count;
SV *json;
char *ret = NULL;
dSP;
ENTER;
SAVETMPS;
count = call_pv("JSON::to_json", G_EVAL | G_SCALAR);
SPAGAIN;
if (SvTRUE(ERRSV)) {
(void )POPs;
Perl_croak(aTHX_ "Error JSON serializing: %s\n",
ecret
RequestParams
RequestMethod
)];
use MooseX::Types::Moose qw/Str HashRef/;
use JSON::XS;
use MooseX::Getopt::OptionTypeMap;
subtype EnvVar,
as Str,
where { grep {defined &&
ap(
RequestParams , '=s'
);
coerce RequestParams,
from Str,
via {
decode_json($_);
};
enum RequestMethod , qw(get put post delete);
coerce RequestMethod,
from Str,
cation/json" },
qq[{ "app": "<%= $class %>", "version" : "$<%= $class %>::VERSION" }])
->status_is(200, "posted version");
$t->get_ok('/clustericious/<%= $class %>')
->json_conten
--method paramter to make post, put, and delete calls (get is default)
and --params to pass in a JSON string of parameters
getsy --sandbox --path '/listings/51455722' --params '{"title" : "chang
:Getsy::OAuth;
use File::HomeDir qw(home);
use File::Spec::Functions qw(catfile);
use JSON::XS;
use MooseX::Getopt;
use MooseX::Types::Moose qw/Str HashRef/;
use WWW::Getsy::Ty
hod decode(Str $json) {
decode_json $json;
}
method encode(HashRef $json) {
JSON::XS->new->utf8->pretty->encode($json);
}
method pretty_print(Str $json) {
pri
o '["help"]' > hubot-scripts.json
$ hubot
hubot> hubot help
hubot> exit
=head1 DESCRIPTION
=head2 CONFIGURATION
describe scripts name to F<hubot-scripts.json>
example)
[
"he