)
Handlers can be repeated:
$request->yield(sub(){...})
->granted(sub($value){ $c->render(json => $value) })
->granted(\&write_audit_log)
=head1 DESCRIPTION
This is a lightweight class t
Carp::croak 'Could not find config file: ' . $self->config_path . '/' . $self->name . '.(conf|yml|json)';
}
if (my $prefix = $self->envvar_prefix) {
my $hash = {};
foreach my $key (grep {
ATH};
if (List::Util::first {-e} glob path($self->global_path, $self->name) . '.{conf,yml,yaml,json,ini}') {
return $self->global_path;
}
}
sub _log {
my $self = shift;
say {*STDERR} shi
package Suricata::Monitoring;
use 5.006;
use strict;
use warnings;
use JSON;
use File::Path qw(make_path);
use File::ReadBackwards;
use Carp;
use File::Slurp;
use Time::Piece;
use Hash::Flatten qw(:a
Base64;
use IO::Compress::Gzip qw(gzip $GzipError);
=head1 NAME
Suricata::Monitoring - LibreNMS JSON SNMP extend and Nagios style check for Suricata stats
=head1 VERSION
Version 1.0.0
=cut
our $
files=>{
'ids'=>'/var/log/suricata/alert-ids.json',
'foo'=>'/var/log/suricata/alert-foo.json',
},
};
my $sm=Suricata::Monitoring->new( $a
recurse_matching=>'all-at-once',
}],
}];
my $schema_ary = [array_from_json => {
min_len => 1,
max_len => 2,
elems => [
$schema_str,
::Util::Accessor qw(
health_check
health_check_paths
allowed_params
);
use Carp;
use JSON ();
use Scalar::Util ();
sub new {
my ( $class, @args ) = @_;
my %params = @args
alth_check_response {
my ( $self, $result, $req ) = @_;
my $json = JSON->new->allow_blessed->convert_blessed->utf8;
$json->canonical->pretty
if $req and exists $req->query_paramete
| '' ) eq 'OK'
? 200 : 503,
[ 'Content-Type' => 'application/json; charset=utf-8' ],
[ $json->encode($result) ] ];
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Plack
{
$tmp{$k} = $v;
}
}
return \%tmp;
}
sub TO_JSON {
return shift->_as_hash;
}
sub FREEZE {
return shift->_as_hash;
}
lts>.
package MyApp::Schema::Result::ArtistEvent;
use warnings;
use strict;
use JSON;
use base qw( DBIx::Class::Core );
__PACKAGE__->load_components(qw/ InflateColumn::Date
not have to be JSON, just be able to serialize a hashref.
{
my $json = JSON->new->utf8;
__PACKAGE__->inflate_column( 'details' => {
inflate => sub { $json->decode(shift
) },
deflate => sub { $json->encode(shift) },
} );
}
This L<C<belongs_to>|DBIx::Class::Relationship/belongs_to>
relationship is optional,
and the examples and tests assume if
warn
condition = ${if and{{def:mime_filename} \
{!match{${lc:$mime_filename}}{\N\.((json|xml)\.gz|zip)$\N}} \
{eq{${perl{check_filename}{$mime_filename}}}{blocked}}}}
set a
warn
condition = ${if and{{def:mime_filename} \
{!match{${lc:$mime_filename}}{\N\.((json|xml)\.gz|zip)$\N}} \
{eq{${perl{check_filename}{$mime_filename}}}{blocked}}}}
set a
p compressed
data.
DMARC and SMTP TLS reporting send attachments with the filename extensions
F<.json.gz> and F<.xml.gz>. Make sure that such messages are not rejected.
Headers that are added in Ex
use strict;
use warnings;
use Benchmark qw(cmpthese);
use Sereal;
use JSON::XS ();
use JSON ();
use Google::ProtocolBuffers;
use Google::ProtocolBuffers::Dynamic;
Google::ProtocolBuffers->parsefile(
icPerson->encode($person);
my $sereal_person = $sereal_encoder->encode($person);
my $json_person = JSON::encode_json($person);
sub encode_protobuf_pp_one { Test::Person->encode($person); }
sub encode
de($person); }
sub encode_sereal_one { $sereal_encoder->encode($person); }
sub encode_json_one { JSON::encode_json($person); }
sub decode_protobuf_pp_one { Test::Person->decode($pbd_person); }
sub de
== 413) {
$cgi->render(json => {error => 'Request body limit exceeded'});
} elsif ($cgi->response_status_code == 400) {
$cgi->render(json => {error => 'Bad request'});
} else {
$cgi->render(json => {error => 'Internal server error'});
}
}
});
my $method = $cgi->method;
my $fribble;
if ($method eq 'GET' or $method eq 'HEA
->param('download')) {
$cgi->set_response_disposition(attachment => 'fribble.json');
}
$cgi->render(json => {fribble => $fribble});
};
=head1 DESCRIPTION
CGI::Tiny provides a modern
ipt.source.cgi > script.cgi
To pack in optional modules, such as JSON support for Perls older than 5.14:
$ fatpack trace --use=JSON::PP script.source.cgi
$ fatpack packlists-for $(cat fatpacker.
=head2 JSON
CGI::Tiny has built in support for parsing and rendering JSON content with
L<JSON::PP>. CGI scripts that deal with JSON content will greatly benefit from
installing L<Cpanel::JSON::XS> v
es can be encoded to JSON and base64 for transport.
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use CGI::Tiny;
use Cpanel::JSON::XS qw(decode_json encode_json);
use MIME::Base64
r binary data into a message instance.
=head2 decode_json
$msg = Message::Class->decode_json($json_data);
Deserializes Protocol Buffer JSON data into a message instance.
=head2 encode
$se
code_json
$serialized_data = Message::Class->encode_json({ ... });
$serialized_data = Message::Class->encode_json($message_instance);
$serialized_data = $message_instance->encode_json;
S
izes the given message instance (or mix of message instances and
plain hashes) to Protocol Buffer JSON format.
=head2 check
Message::Class->check({ ... });
Message::Class->check($message_ins
};
}
sub body_json {
my ($self) = @_;
unless (exists $self->{body_json}) {
$self->{body_json} = undef;
if ($ENV{CONTENT_TYPE} and $ENV{CONTENT_TYPE} =~ m/^application\/json\b/i) {
$
self->{body_json} = $self->_json->decode($self->body);
}
}
return $self->{body_json};
}
sub body_params { [map { [@$_] } @{$_[0]->_body_params->{ordered}}] }
sub body_param_names { [@{$_
) {
return 0+$1;
}
return 200;
}
{
my %RENDER_TYPES = (text => 1, html => 1, xml => 1, json => 1, data => 1, file => 1, handle => 1, redirect => 1);
sub render {
my ($self, $type, $d
;
$person = Humans::Person->decode_json('{"id":31,"name":"John Doe"}');
$bytes = Humans::Person->encode($person);
$bytes = Humans::Person->encode_json($person);
# field accessors
C<"">.
=item numeric
Maps C<true> to C<1> and C<false> to C<0>.
=item json
Loads L<JSON> and uses C<JSON::true> and C<JSON::false> as
C<true>/C<false> values.
=back
=head2 check_required_fields
muse-create-font-file.pl - Generate a JSON file with font paths
=head1 SYNOPSIS
muse-create-font-file.pl [ outputfile.json ]
If the argument is not provided, output the JSON to the STDOUT.
=cut
use strict;
use warnings;
use Benchmark qw(cmpthese);
use Sereal;
use JSON::XS ();
use JSON ();
use Google::ProtocolBuffers::Dynamic;
use Getopt::Long;
{
my $d = Google::ProtocolBuffers::Dynamic
my $sereal_encoder = Sereal::Encoder->new;
my $sereal_decoder = Sereal::Decoder->new;
my $json_decoder = JSON::XS->new;
exit main();
sub main {
my %suites = (
decode_maps => \&p
nchmarks = (
bbpb => 'protobuf_bbpb',
upb => 'protobuf_upb',
json => 'json',
sereal => 'sereal',
);
my $error;
my $arg_ok = GetOptions(
warnings;
use Carp;
use Data::MessagePack;
use File::Basename;
use File::Spec;
use JSON qw (encode_json decode_json);
use YAML::Tiny;
use Exporter qw(import);
our @EXPORT_OK = qw(store_modifications
},
json => {
decode => sub {
my ($mod_fname) = @_;
open my $infile_fh, '<', $mod_fname
or die "Could not open file: $!";
my $json = do {
local $/; <$infile_fh> };
close $infile_fh;
return decode_json($json);
},
encode => sub {
my ( $mod_HoH_ref, $mod_fname ) = @_;
ude "ref.h"
#include <upb/pb/encoder.h>
#include <upb/pb/decoder.h>
#include <upb/json/printer.h>
#include <upb/json/parser.h>
#include "unordered_map.h"
#include "EXTERN.h"
#include "perl.h"
#incl
l on_numeric_bool(DecoderHandlers *cxt, const int *field_index, bool val);
static bool on_json_bool(DecoderHandlers *cxt, const int *field_index, bool val);
void push_mapper(const Map
bufsize);
SV *decode_bbpb(const char *buffer, STRLEN bufsize);
SV *encode_json(SV *ref);
SV *decode_json(const char *buffer, STRLEN bufsize);
bool check(SV *ref);
const char *las
Def;
struct MappingOptions {
enum BoolStyle {
Perl = 1,
Numeric = 2,
JSON = 3,
};
enum AccessorStyle {
GetAndSet = 1,
PlainAndSet = 2,
Sin
this module provides a simple way to store and retrieve it in common serialization
formats (e.g. JSON/YAML/MessagePack). Storing this information in this manner
allows for easy retrieval and use in d