g DTA::CAB::Analyzer::Dict::JsonDB
=item L<DTA::CAB::Analyzer::Cache::Static::BDB|DTA::CAB::Analyzer::Cache::Static::BDB>
Static cache using DTA::CAB::Analyzer::Dict::JsonDB
=item L<DTA::CAB::Analy
AB::Analyzer::Dict::Json|DTA::CAB::Analyzer::Dict::Json>
generic analysis dictionary API using JSON values
=item L<DTA::CAB::Analyzer::Dict::JsonCDB|DTA::CAB::Analyzer::Dict::JsonCDB>
generic analy
sis dictionary API using JSON values
=item L<DTA::CAB::Analyzer::Dict::JsonDB|DTA::CAB::Analyzer::Dict::JsonDB>
generic analysis dictionary API using JSON values
=item L<DTA::CAB::Analyzer::DmootSu
]
Simple machine-readable "vertical" text format based on the L<TT|/TT>
format but using L<JSON|http://json.org/> to encode sentence- and token-level attributes
rather than an explicit attribute labe
"C<%%$TJ:DOC=>I<JSON>", where I<JSON> is a JSON object representing
auxilliary document attributes.
Sentence-attribute lines are analogousd comments of the form
"C<%%$TJ:SENT=>I<JSON>".
Token lines c
onsist of the the token surface text,
followed by a TAB character,
followed by a JSON object representing the internal token structure.
Useful for further script-based processing.
=cut
##==========
package Google::ISBNNumbers;
use HTTP::Tiny;
use Cpanel::JSON::XS;
use Carp;
use strict;
use warnings;
our $VERSION = "1.00";
sub new {
my ($class, $google_api_key) = @_;
# the API key is requi
self, with an HTTP::Tiny and Cpanel::JSON objects
my $self = bless {
'api_key' => $google_api_key,
'http' => HTTP::Tiny->new,
'json_coder' => Cpanel::JSON::XS->new->utf8->allow_nonref->allow_b
up failed: ".$response->{reason} unless $response->{success};
# translate JSON to data struct
my $results = $self->{json_coder}->decode( $response->{content} );
# must be an array
croak "Inval
tDocument($_[1]); }
## $fmt = $fmt->putData($data)
## + put arbitrary raw data (e.g. for YAML, JSON, XmlPerl)
sub putData {
$_[0]->logconfess("putData() not implemented!");
}
1; ##-- be happy
_
/format.html>
format, with optional special handling for additional C<MISC> fields, including
C<json=JSON> for embedding L<DTA::CAB::Format::TJ|DTA::CAB::Format::TJ> CAB-token structure.
Registered as
mat::JSON|DTA::CAB::Format::JSON>
Abstract datum parser|formatter for JSON I/O.
Transparently wraps one of the
L<DTA::CAB::Format::JSON::XS|DTA::CAB::Format::JSON::XS>
or
L<DTA::CAB::Format::JSON::Sy
turn DTA::CAB::Document->new(@_); ##-- default
}
## $thingy = $obj->TO_JSON()
## + annoying wrapper for JSON::XS
sub TO_JSON {
return { %{$_[0]} };
}
1; ##-- be happy
__END__
##===============
$c->render('json' => { job => $j });
};
get '/state/:id' => sub {
my $c = shift;
my $job = $c->minion->job($c->stash('id'));
$c->render('json' => { job => $c->
in/env perl
use Mojolicious::Lite;
plugin 'Config';
get '/' => sub {
my $c = shift;
my $json = {
"entities" => {
"Q100148272" => {
"id" => "Q100148272",
"sitelinks" =
"type" => "item"
}
},
"success" => 1
};
$c->render(json => $json);
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
<h1>Wel
use Mojo::Util qw/dumper/;
use Mojo::Response::JSON::Path;
use Mojo::UserAgent;
use Time::HiRes qw/time/;
$\ = "\n"; $, = "\t";
my $ua = Mojo::UserAgent->new;
my $url = Mojo::URL->new("http://local
;
my $json = $tx->res->json('$.entities');
print dumper $json;
}
print time() - $start;
# print dumper $json;
# print dumper $tx->res->json('//title');
# my $u = Weirdo->new($json);
# pri
=head1 Mojo::Response::JSON::Path - use JSON::Path for searching JSON responses
=head2 SYNOPSIS
use Mojo::Response::JSON::Path;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
;
my $json = $tx->res->json('$.entities');
=head2 DESCRIPTION
This module allows the use of an optional JSON Path expression to extract a specific value from a Mojo::Message via JSON::Path.
=head2 FUNCTIONS
None
=head2 SEE ALSO
Related modules: L<Mojo::Message>, L<Mojo::JSON::Pointer>, L<JSON::Path>
=head2 AUTHORS
Simone Cesano
=head2 COPYRIGHT AND LICENSE
This software is copyri
use strict 'vars';
use warnings;
our $VERSION='0.15';
use parent 'HTTP::Request';
use JSON;
use Crypt::JWT qw(encode_jwt);
use MIME::Base64 qw( encode_base64url decode_base64url);
use C
ref $subscription eq 'HASH') {
$agent=$subscription;
} else {
eval {$agent=from_json($subscription); };
}
croak "Can't process subscription object" unless ($agent);
cro
ent using the browser's Push API C<PushManager.subscribe()> method. The argument can
be either a JSON string or a previously setup hash reference. The HTTP::Request uri is taken verbatim from the end
alyzer::EqPho::JsonCDB.pm
## Author: Bryan Jurish <moocow@cpan.org>
## Description: dictionary-based equivalence-class expander, phonetic variant
package DTA::CAB::Analyzer::EqPho::JsonCDB;
use DTA::
CAB::Analyzer ':child';
use DTA::CAB::Analyzer::Dict::JsonCDB;
use strict;
##==============================================================================
## Globals
##==============================
================================================
our @ISA = qw(DTA::CAB::Analyzer::Dict::JsonCDB);
##==============================================================================
## Constructors et
mmand::webpush;
use Mojo::Base 'Mojolicious::Command';
use Mojo::JSON qw(encode_json decode_json);
use Crypt::PK::ECC;
my %COMMAND2JSON = (
create => [ 1 ],
);
my %COMMAND2CB = (
keygen => \&_key
$cmd};
$args[$_] = decode_json($args[$_]) for @{ $COMMAND2JSON{$cmd} || [] };
$cmd .= "_p";
$self->app->webpush->$cmd(@args)->then(
sub { print STDOUT encode_json(@_), "\n" },
sub { prin
SYNOPSIS
Usage: APPLICATION webpush COMMAND [OPTIONS]
./myapp.pl webpush create <USERID> <JSON>
./myapp.pl webpush read <USERID>
./myapp.pl webpush delete <USERID>
./myapp.pl webpu
!$self->{response};
my (@vars, $value, @values, $v, $request_body_type, $request_body_content, $json_params, $plack_headers, @plack_uploads, $plack_upload, $uploaded_filename);
# stash the hostnam
t JSON data structures
$request_body_type = $self->{request}->content_type;
$request_body_content = $self->{request}->content;
if ($request_body_content && $request_body_type eq 'application/json')
{
$json_params = $self->{utils}->json_to_perl($request_body_content);
if (ref($json_params) eq 'HASH') {
$self->{params} = $json_params;
}
}
# the rest of this is to accept any POST / GET
Utilities::VERSION = '1.5';
# for utf8 support with JSON
use utf8;
use Encode qw( encode_utf8 );
# for encoding and decoding JSON
use Cpanel::JSON::XS;
# for logging via logger()
use Path::Tiny;
us
y $self = bless {
'request' => $$args{request},
'response' => $$args{response},
'json_coder' => Cpanel::JSON::XS->new->utf8->allow_nonref->allow_blessed,
'config_file' => $ENV{HOME}.'/pepper/c
return $self;
}
### START METHODS FOR GENERATING RESPONSES AND LOGS
# method to deliver html & json out to the client;
# this must be in here to be available even if not in plack mode
sub send_resp
oint_uri = ?
}, [ $endpoint ] );
# or maybe a JSON file
} elsif ($self->{config}{url_mappings_file}) {
my $url_mappings = $self->read_json_file( $self->{config}{url_mappings_file} );
$
r = Pepper->new();
The $pepper object provides several conveniences for MySQL/MariaDB databases, JSON
parsing, Template Toolkit, file handling and logging. In Web/Plack mode,
$pepper will also incl
/127.0.0.1:5000 (or in your
browser, using your server's hostname:5000). You should receive basic JSON results.
Modify PepperExample.pm to tweak those results and then restart the Plack service
to t
ackage Mojolicious::Plugin::WebPush;
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::JSON qw(decode_json encode_json);
use Mojo::URL;
use Crypt::PK::ECC;
use MIME::Base64 qw(encode_base64url decode_ba
ata.json();
var title = msg.title;
delete msg.title;
event.waitUntil(self.registration.showNotification(title, msg));
}
EOF
sub _decode {
my ($bytes) = @_;
my $body = eval { decode_json($by
equest") if $@;
(1, $body);
}
sub _error {
my ($c, $error) = @_;
$c->render(status => 500, json => { errors => [ { message => $error } ] });
}
sub _make_route_handler {
my ($subs_session2use
rs sent via GET/POST or JSON body are available
# within $pepper->{params}
#
# Simply return your prepared content and Pepper will deliver
# it to the client. To send JSON, return a reference to
epper will send it out to the client
# sending a data structure back will send that structure in JSON to the client
# you can alse return HTML or any text
return $starter_content;
}
1;
];
}
#
evious cookie.
<br/><br/>
<strong>Return JSON:</strong>
<br/><input type="checkbox" name="return_json" value="yes"/> Click to have the response be JSON instead of HTML.
<br/>Leave un-checked to
Lite;
plugin 'ServerType';
get '/' => sub {
my $c = shift;
$c->render( json => {"serverType" => $c->app->server_type } );
};
app->start;
=head1 DESCRIPTION
Mojoli
pepper set-endpoint'.
This is a faster option for handling requests, but you may leave blank for JSON config file.}],
['default_endpoint_module',
qq{
Default endpoint-handler Perl module.
This
s';
} else {
$$config{url_mappings_file} = $self->{pepper_directory}.'/config/pepper_endpoints.json';
}
# default endpoint handler
$$config{default_endpoint_module} ||= 'PepperApps::PepperExamp
mappings{$$map[0]} = $$map[1];
}
# or maybe a JSON file
} elsif ($utils->{config}{url_mappings_file}) {
$url_mappings = $utils->read_json_file( $utils->{config}{url_mappings_file} );
}
e JSON;
__PACKAGE__->mk_accessors(qw/ sns arn /);
sub Publish
{
my ($self, $msg, $subj, $attr) = @_;
# XXX croak on invalid arn
my $structure = undef;
my $attributes = undef;
# support JSON
payload
if (ref($msg) eq 'HASH') {
$structure = 'json';
$msg = encode_json($msg);
}
if (defined($attr) and ref($attr) eq 'HASH') {
my $i = 1;
foreach my $key (keys %$attr) {
$attrib