package eris::role::schema;
# ABSTRACT: Role for implementing a schema
use eris::dictionary;
use JSON::MaybeXS;
use Moo::Role;
use POSIX qw(strftime);
use Types::Standard qw(Bool HashRef InstanceOf I
}
sub as_bulk {
my ($self,$log) = @_;
return sprintf "%s\n%s\n",
map { encode_json($_) }
{
index => {
_index => strftime($self->index_name, gmti
ead1 METHODS
=head2 as_bulk
Takes an L<eris::log> object and returns the bulk newline delimited JSON to add
that object to the cluster.
=head2 to_document
Takes an L<eris::log> object and returns
g::decoders>, L<eris::log::contextualizer>, L<eris::log::decoders::syslog>,
L<eris::log::decoder::json>
=head1 AUTHOR
Brad Lhotsky <brad@divisionbyzero.net>
=head1 COPYRIGHT AND LICENSE
This softw
D::MemberAPI;
use strict;
use warnings;
our $VERSION = 0.0402;
use Moo::Role;
use JSON qw(decode_json encode_json);
use namespace::clean;
with 'WWW::ORCID::API';
has read_limited_token => (is =>
ath = shift;
my $data = shift;
my $opts = ref $_[0] ? $_[0] : {@_};
my $body = encode_json($data);
my $url = _url($self->api_url, $path, $opts);
my $res = $self->_t->post($url, $
encode_json($data);
my $url = _url($self->api_url, $path, $opts);
my $res = $self->_t->put($url, $body, _headers($opts, 1, 1));
if ($res->[0] eq '200') {
return decode_json($res-
use strict;
use warnings;
our $VERSION = 0.0402;
use Class::Load qw(try_load_class);
use JSON qw(decode_json);
use Sub::Quote qw(quote_sub);
use Carp;
use Moo::Role;
use namespace::clean;
with 'WWW
$headers = {'Accept' => 'application/json'};
my $res = $self->_t->post_form($url, $opts, $headers);
if ($res->[0] eq '200') {
return decode_json($res->[2]);
}
$self->_set_las
$headers->{'Accept'} = 'application/vnd.orcid+json';
}
if ($add_content_type) {
$headers->{'Content-Type'} = 'application/vnd.orcid+json';
}
$headers;
}
sub _clean {
my (
se warnings;
use CLI::Helpers qw(:output);
use Data::Printer;
use Hash::Flatten qw(flatten);
use JSON::MaybeXS;
use Getopt::Long::Descriptive;
use YAML;
use eris::log::contextualizer;
use eris::sche
['bulk|b', "Show the bulk output from the schema match instead." ],
['json|j', "Show the structure are JSON." ],
['flatten|F', "Flatten the hash keys, defaults to false."],
['c
lk ) {
output({data=>1}, $schm->as_bulk($l));
}
elsif( $opt->json ) {
output({data=>1}, encode_json($v));
}
else {
p($v);
}
}
__END__
=pod
=encoding UTF-
ackage VoIPms;
use 5.024001;
use strict;
use warnings;
use URI::Escape;
use WWW::Mechanize;
use JSON::XS;
sub new {
my $type = shift;
my %params = @_;
if (!defined $params{api_username}
ey});
}
my $response = $self->{mechanize}->get($get)->content;
my $json = JSON::XS->new;
return $json->decode($response);
}
our @ISA = qw(Exporter);
our @EXPORT = qw( new response
ms
API, as listed here: https://www.voip.ms/m/apidocs.php
Responses from VoIP.ms are provided as JSON but are decoded and
returned as pure Perl.
=head2 EXPORT
None.
=head1 HISTORY
=over 8
=item
g, or 99 if cannot determine for sure. To see the more detailed
note, you can run the CLI with `--json` to return the whole enveloped response.
_
};
sub systemd_is_running {
my %args = @_;
m
, or 99 if cannot determine for sure. To see the more detailed
note, you can run the CLI with C<--json> to return the whole enveloped response.
This function is not exported by default, but exportabl
package MarpaX::Demo::JSONParser;
use strict;
use warnings;
use File::Basename; # For basename.
use File::Slurper 'read_text';
use Marpa::R2;
use MarpaX::Demo::JSONParser::Actions;
use MarpaX::Sim
eq 'json.1.bnf')
{
$self-> grammar
(
Marpa::R2::Scanless::G -> new
({
default_action => 'do_first_arg',
source => \$bnf,
})
)
}
elsif ($self -> base_name eq 'json.2.b
G -> new
({
bless_package => 'MarpaX::Demo::JSONParser::Actions',
source => \$bnf,
})
)
}
elsif ($self -> base_name eq 'json.3.bnf')
{
$self-> parser
(
gen_parser
(
package MarpaX::Demo::JSONParser::Actions;
use strict;
use warnings;
# Warning: Do not use Moo or anything similar.
# This class needs a sub new() due to the way
# Marpa calls the constructor.
our
aX::Demo::JSONParser::Actions> - A JSON parser with a choice of grammars
=head1 Synopsis
See L<MarpaX::Demo::JSONParser/Synopsis>.
The module is used automatically by L<MarpaX::Demo::JSONParser> as
appropriate.
=head1 Description
See L<MarpaX::Demo::JSONParser/Description>.
=head1 Installation
See L<MarpaX::Demo::JSONParser/Installation>.
=head1 Methods
The functions are called automatica
package Test::APIcast::Blackbox;
use strict;
use warnings FATAL => 'all';
use v5.10.1;
use JSON;
use Test::APIcast -Base;
use File::Copy "move";
use File::Temp qw/ tempfile /;
use File::Slurp qw(read
erverPort;
}
_EOC_
}
my $configuration_format = $block->configuration_format || 'json';
if (defined $configuration) {
$configuration = Test::Nginx::Util::expand_env_in_co
::fail("$name - configuration block JSON") || Test::More::diag $_[0];
};
if ($configuration_format eq 'json') {
decode_json($configuration);
}
he list of plugins. I usually put it into my top-level config file (i.e. F<~/.TimeTracker/tracker.json>).
=head2 other setup
Turn F<~/.TimeTracker> into a git repository and make sure you
can pull/p
ings;
use MarpaX::Demo::JSONParser;
use Try::Tiny;
# ---------------------------
my($app_name) = 'MarpaX-Demo-JSONParser';
my($bnf_name) = shift || 'json.1.bnf'; # Or 'json.2.bnf'.
my($bnf_file) =
$message);
my($result);
# Use try to catch die.
try
{
$message = '';
$result = MarpaX::Demo::JSONParser -> new(bnf_file => $bnf_file) -> parse($string);
}
catch
{
$message = $_;
$result = 0;
}
package WebService::Antigate::V2;
use strict;
use JSON::PP;
use MIME::Base64;
use parent 'WebService::Antigate';
sub new {
my ($class, %args) = @_;
# change some defaults
$args{schem
->post(
"$self->{scheme}://$self->{subdomain}$self->{domain}/createTask",
Content => encode_json {
clientKey => $self->{key},
exists $opts{softId} ? ( softId => delete $opts{softId} ) :
$self->{errstr} = $response->status_line;
return undef;
}
my $result = decode_json $response->decoded_content;
if ($result->{errorId}) {
$self->{errno} = $result->{errorCode};
es;
use HTML::Form;
use LWP::UserAgent::Determined;
use Carp qw(longmess shortmess);
use CGI;
use JSON::XS;
use Data::Dumper;
use GRNOC::Config;
use Time::HiRes qw(gettimeofday tv_interval);
use File:
) {
return $res;
}
#--- default is to return json hash
# <editorialize>
# @#$*(@#$%($% library functions should alw
) is neigh.
# JSON:XS doesn't do this. Hence the eval.
# </editorialize>
my $str;
eval { $str = decode_json( $res ) };
i
'Test::DBChanges::Role::Base',
'Test::DBChanges::Role::Triggers',
'Test::DBChanges::Role::JSON';
our $VERSION = '1.0.2'; # VERSION
# ABSTRACT: installs triggers for PostgreSQL
sub maybe_pre
ename} (
id SERIAL PRIMARY KEY,
table_name VARCHAR NOT NULL,
operation VARCHAR NOT NULL,
data JSONB NOT NULL,
done_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
)
SQL
my $procname = "${
)
VALUES (TG_TABLE_NAME,TG_OP,row_to_json(OLD));
ELSE
INSERT INTO ${tablename} (table_name,operation,data)
VALUES (TG_TABLE_NAME,TG_OP,row_to_json(NEW));
END IF;
RETURN NULL;
END;
\$
pass raw output from the service instead of trying to
--raw decode it as json This is a boolean field and does not
require an argument.
-l
data_type => "varchar",
is_nullable => 0,
size => 1024,
},
json => {
data_type => "varchar",
is_nullable => 1,
},
created => {
ate_column (
json => {
inflate => sub {
return JSON::XS->new->utf8->relaxed->shrink->decode($_[0]);
},
deflate => sub {
return JSON::XS->new->utf8->
d1 ACCESSORS
=head2 name
data_type: 'varchar'
is_nullable: 0
size: 1024
=head2 json
data_type: 'json'
is_nullable: 1
=head2 created
data_type: 'timestamp with time zone'
default_va
#use diagnostics;
use Authen::Captcha;
use JSON::XS;
use XML::Simple;
use CGI::Carp qw(fatalsToBrowser);
require Exporter;
use vars qw(
$m_outXML
$m_sJson
$m_bMainTemplate
$DefaultClass
$ACC
$m_sAction = ( $m_sAction =~ /^(\w{3,50})$/ ) ? $1 : $m_hrSettings->{defaultAction};
$m_sJson = {
m_sCurrentAction => $m_sAction,
m_nRight => $m_nRight,
m_nHtm
?>\n<xml>\n\n);
$m_sJson->{m_sSid} = $m_sSid;
my $encode_json = encode_json $m_sJson;
print qq|<output id="sid"><![CDATA[
<script>
m_sJson = '$encode_json';
m_sid = "$m_s
@path);
if ($row) {
return Data::Context::Loader::DB->new(
raw => $row->json,
);
}
elsif ($row = $self->schema->resultset($self->table)->find(join '/', @path[
- 2], $self->default)) {
return Data::Context::Loader::DB->new(
raw => $row->json,
);
}
return;
}
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 NAME
D
:Dumper qw/Dumper/;
use English qw/ -no_match_vars /;
use Data::Context::Util qw/do_require/;
use JSON::XS;
our $VERSION = version->new('0.0.1');
extends 'Data::Context::Loader';
sub changed {