::Slurp;
use Getopt::Long qw[GetOptionsFromArray :config gnu_compat bundling no_auto_abbrev];
use JSON::XS;
use List::Util qw[max uniq];
use Net::IP::XS;
use Pod::Usage;
use POSIX qw[setlocale LC_MESS
ngine;
use Zonemaster::LDNS;
our %numeric = Zonemaster::Engine::Logger::Entry->levels;
our $JSON = JSON::XS->new->allow_blessed->convert_blessed->canonical;
our $SCRIPT = $0;
Readonly our $EXIT_
= undef;
my $opt_ipv6 = undef;
my $opt_json = undef;
my $opt_json_stream = 0;
my $opt_json_translate = undef;
my $opt_level = 'NOTICE';
m
;
use Mojo::Cache;
use Mojo::DynamicMethods;
use Mojo::File qw(curfile path);
use Mojo::JSON qw(encode_json);
use Mojo::Loader qw(data_section);
use Mojo::Util qw(decamelize deprecated encode gz
{text}), $options->{format} if defined $stash->{text};
# JSON
return encode_json(delete $stash->{json}), 'json' if exists $stash->{json};
# Template or templateless handler
$options->{templa
licious::Controller->new);
my $best = $renderer->accepts(Mojolicious::Controller->new, 'html', 'json');
Select best possible representation for L<Mojolicious::Controller> object from C<format> C<GE
=====================
## NAME
=pod
=head1 NAME
DiaColloDB::Document::JSON - diachronic collocation db, source document, raw JSON
=cut
##============================================================
==================================================
## PRELIMINARIES
use DiaColloDB::Document::JSON;
##========================================================================
## Constructors e
DESCRIPTION
DiaColloDB::Document::JSON
provides a L<DiaColloDB::Document|DiaColloDB::Document>-compliant API
for parsing corpus files in raw L<JSON|http://www.json.org> format,
assuming the stored d
: $DiaColloDB::threads::MODULE);
##-- avoid heinous death with JSON::XS backend using threads
$DDC::Client::JSON_BACKEND = 'JSON::PP';
}
##=====================================================
olloDB::Profile::Multi->xkeys(\@mps);
#$cli->trace("extend(): xkeys=", DiaColloDB::Utils::saveJsonString($xkeys, utf8=>0));
#$cli->trace("extend(): N.pre=", join('+',map {$_->{profiles}[0]{N}}
$_[1]);
$sub->extend($rel,%opts,strings=>1,score=>'f',cutoff=>'',fill=>1,slice2keys=>JSON::to_json($xkeys->[$_[1]], {allow_nonref=>1}))
or $_[0]->logconfess("extend() failed for client ur
od('GET');
$tx->req->url->parse('http://example.com');
$tx->req->headers->accept('application/json');
say $tx->res->code;
say $tx->res->headers->content_type;
say $tx->res->body;
say $tx->
ColloDB::MultiMapFile::MMap;
use DiaColloDB::MultiMapFile;
use DiaColloDB::Utils qw(:fcntl :file :json :pack);
use File::Map qw(map_handle);
use strict;
##============================================
;
use utf8;
package JSON::Relaxed;
use JSON::Relaxed::Parser; our $VERSION = $JSON::Relaxed::Parser::VERSION;
=encoding UTF-8
=head1 NAME
JSON::Relaxed -- An extension of JSON that allows for bet
=head1 Relaxed JSON?
There's been increasing support for the idea of expanding JSON to improve
human-readability.
"Relaxed" JSON (RJSON) is a term that has been used to describe a
JSON-ish format tha
that JSON doesn't.
Most notably, RJSON allows the use of JavaScript-like comments and
eliminates the need to quote all keys and values.
An (official) specification can be found on
L<RelaxedJSON.org|h
qr/\w+/];
my $route = under '/:foo' => (agent => qr/Firefox/);
my $route = under [format => ['json', 'yaml']];
Generate nested route with L<Mojolicious::Routes::Route/"under">, to which all follo
g'],
jpg => ['image/jpeg'],
js => ['application/javascript'],
json => ['application/json;charset=UTF-8'],
mp3 => ['audio/mpeg'],
mp4 => ['video/mp4'],
peg -> image/jpeg
jpg -> image/jpeg
js -> application/javascript
json -> application/json;charset=UTF-8
mp3 -> audio/mpeg
mp4 -> video/mp4
ogg -> audio/og
ing new ones.
=head2 content_type
$types->content_type(Mojolicious::Controller->new, {ext => 'json'});
Detect MIME type for L<Mojolicious::Controller> object unless a C<Content-Type> response hea
-----------------------------------------------------------
## DESCRIPTION: DiaColloDB::Document::JSON: Globals & Constants
=pod
=head2 Globals & Constants
=over 4
=item Variable: @ISA
DiaColloDB:
-----------------------------------------------------------
## DESCRIPTION: DiaColloDB::Document::JSON: Constructors etc.
=pod
=head2 Constructors etc.
=over 4
=item new
$doc = CLASS_OR_OBJECT->n
-----------------------------------------------------------
## DESCRIPTION: DiaColloDB::Document::JSON: API: I/O: parse
=pod
=head2 API: I/O: parse
=over 4
=item fromFile
$bool = $doc->fromFile($
lt returns "$obj->{base}.hdr" or "$obj->{dbdir}/header.json"
sub headerFile {
return undef if (!ref($_[0]));
return "$_[0]{dbdir}/header.json" if (defined($_[0]{dbdir}));
return "$_[0]{base}.hdr
# $str = $obj->saveHeaderString(%opts)
## + returns JSON string for object header data
sub saveHeaderString {
return DiaColloDB::Utils::saveJsonString($_[0]->headerData, @_[1..$#_]);
}
## $bool =
->saveHeaderFile($filename_or_handle, %opts)
sub saveHeaderFile {
return DiaColloDB::Utils::saveJsonFile($_[0]->headerData, @_[1..$#_]);
}
## $bool = $obj->saveHeader()
## $bool = $obj->saveHeader(
## + opens a local file url
## + may re-bless() $cli into an appropriate package
## + loads a JSON config file containing one or more of the following keys:
## (
## class => $CLASS, ##-- bl
se Compress::Raw::Zlib qw(Z_SYNC_FLUSH);
use List::Util qw(first);
use Mojo::JSON qw(encode_json j);
use Mojo::Util qw(decode encode trim);
use Mojo::WebSocket qw(WS_BIN
text => encode('UTF-8', $frame)} if ref $frame ne 'HASH';
# JSON
$frame->{text} = encode_json($frame->{json}) if exists $frame->{json};
# Raw text or binary
if (exists $frame->{text}) { $f
urn $self->finish(1009) if length $msg;
$msg = $out;
}
$self->emit(json => j($msg)) if $self->has_subscribers('json');
$op = delete $self->{op};
$self->emit($op == WS_TEXT ? 'text' : 'bin
my %RESERVED = map { $_ => 1 } (
qw(action app cb controller data extends format handler inline json layout namespace path status template text),
qw(variant)
);
sub BUILD_DYNAMIC {
my ($class,
r->parse('/user/:id');
$r = $r->parse('/user/:id', id => qr/\d+/);
$r = $r->parse(format => ['json', 'yaml']);
Parse pattern.
=head2 patch
my $route = $r->patch;
my $route = $r->patch('/:fo
my $route = $r->under('/:foo' => (agent => qr/Firefox/));
my $route = $r->under([format => ['json', 'yaml']]);
Generate L<Mojolicious::Routes::Route> object for a nested route with its own inter
->req->params->to_hash;
my $all = $tx->req->uploads;
my $value = $tx->req->json;
my $foo = $tx->req->json('/23/foo');
my $dom = $tx->req->dom;
my $bar = $tx->req->dom('div.bar')
tes = $tx->res->body;
my $str = $tx->res->text;
my $value = $tx->res->json;
my $foo = $tx->res->json('/23/foo');
my $dom = $tx->res->dom;
my $bar = $tx->res->dom('div.bar
TY
our $VERSION = '0.001'; # VERSION
use Carp;
use File::Slurp;
use JSON::MaybeXS qw(decode_json encode_json);
use Crypt::PRNG;
use Net::SSH::Perl::Cipher;
use Blockchain::Ethereum::Keyst
ub id {
shift->{id};
}
sub private_key {
shift->{private_key};
}
sub _json {
return shift->{json} //= JSON::MaybeXS->new(utf8 => 1);
}
sub import_file {
my ($self, $file_path, $pass
word) = @_;
my $content = read_file($file_path);
my $decoded = $self->_json->decode(lc $content);
return $self->_from_object($decoded, $password);
}
sub _from_object {
my ($self, $o
w(croak);
use Mojo::Asset::Memory;
use Mojo::Content::Single;
use Mojo::DOM;
use Mojo::JSON qw(j);
use Mojo::JSON::Pointer;
use Mojo::Parameters;
use Mojo::Upload;
use Mojo::Util qw(decode);
has cont
ift->{limit} }
sub json {
my ($self, $pointer) = @_;
return undef if $self->content->is_multipart;
my $data = $self->{json} //= j($self->body);
return $pointer ? Mojo::JSON::Pointer->new($dat
ojo::Headers/"max_line_size">.
=head2 json
my $value = $msg->json;
my $value = $msg->json('/foo/bar');
Decode JSON message body directly using L<Mojo::JSON> if possible, an C<undef> return valu
Corpus::Filters qw(:defaults);
use DiaColloDB::Persistent;
use DiaColloDB::Utils qw(:math :fcntl :json :sort :pack :regex :file :si :run :env :temp :jobs);
#use DiaColloDB::Temp::Vec;
use DiaColloDB::
of dist files for this db
sub diskFiles {
my $coldb = shift;
return ("$coldb->{dbdir}/header.json", map {$_->diskFiles} grep {UNIVERSAL::can(ref($_),'diskFiles')} values %$coldb);
}
##==========
pts{slice2keys}, which is EITHER
## - a HASH-ref {$slice1=>\@keys1, ...},
## OR
## - a JSON-string encoding a such a HASH-ref
## + %opts, as for profile(), except:
## (
## ##-- sele
=========
## I/O: JSON
$thingy = $obj->TO_JSON();
$str = $obj->saveJsonString(%opts);
$bool = $obj->saveJsonFile($filename_or_handle, %opts);
$obj = $CLASS_OR_OBJECT->loadJsonData( $data,%opts)
;
$obj = $CLASS_OR_OBJECT->loadJsonString( $string,%opts);
$obj = $CLASS_OR_OBJECT->loadJsonFile($filename_or_handle,%opts);
##====================================================================
ble methods for
determining disk usage and file timestamps,
text I/O,
and object metadata I/O via JSON header files.
=cut
##----------------------------------------------------------------
## DESCRI
B<OR>
a JSON-string encoding such a HASH-ref.
Options C<%opts> are as for the L<profile()|/profile> method (mostly ignored),
and also:
slice2keys => \%slice2keys, ##-- target f2-items or JSON-string