ures;
use Scalar::Util qw( blessed );
use Yancy::Util qw( load_backend );
use Mojo::JSON qw( encode_json decode_json );
use Mojo::Loader qw( find_modules load_class );
use Mojo::File qw( curfile );
us
# XXX: Make Yancy support this basic CRUD with relationships?
# XXX: Otherwise, add custom JSON API
$self->routes->get( '/plan/create' )
->to( 'plan#edit_plan' )->name( 'zapp.create
'task_id' } ),
];
for my $task ( @$tasks ) {
$task->{input} = decode_json( $task->{input} );
}
my $inputs = $plan->{inputs} = [
$self->yancy->
ALSO
#pod
#pod L<Zapp>
#pod
#pod =cut
use Mojo::Base -base, -signatures;
use Mojo::JSON qw( decode_json encode_json );
use Scalar::Util qw( blessed );
use Mojo::Loader qw( data_section );
#pod =attr
{state} //= "inactive";
# XXX: Auto-encode JSON in Yancy
$data->{config} = encode_json( $data->{config} // {} );
$data->{input} = encode_json( $data->{input} // {} );
return $self->ap
, $trigger_id, $data ) {
# XXX: Auto-encode JSON in Yancy
$data->{config} &&= encode_json( $data->{config} );
$data->{input} &&= encode_json( $data->{input} );
return $self->app->yancy
lot;
}
#pod =sub get_path_from_schema
#pod
#pod Get the schema for a given path out of the given JSON Schema. Will traverse
#pod object C<properties> and array C<items> to find the schema.
#pod
#pod
of the given data.
=head2 get_path_from_schema
Get the schema for a given path out of the given JSON Schema. Will traverse
object C<properties> and array C<items> to find the schema.
=head2 prefix_
t
#pod and an output template to display its output. Task input and output are
#pod declared with JSON Schema (see the L</schema> method), and input will be
#pod processed with L<Zapp::Formula> before
e 'Minion::Job', -signatures;
use List::Util qw( uniq );
use Time::Piece;
use Mojo::JSON qw( decode_json encode_json );
use Zapp::Util qw( get_path_from_data get_path_from_schema );
use Yancy::Util qw
cessible from
# $self->app->zapp->run()
has _context => sub( $self ) {
my $run_input = decode_json( $self->zapp_run->{ input } );
my %context;
for my $input ( @$run_input ) {
my $t
od =head1 SEE ALSO
#pod
#pod =cut
use Mojo::Base 'Zapp::Trigger', -signatures;
use Mojo::JSON qw( decode_json );
use Scalar::Util qw( blessed );
use Yancy::Util qw( currym );
sub install( $self, $ap
$hook;
# XXX: Yancy has no JSON query capability...
for my $h ( $c->yancy->list( zapp_triggers => { type => $self->moniker } ) ) {
# XXX: Auto-decode JSON fields in Yancy
my $c
use LWP::Simple;
use JSON
# Load credentials from internal web server.
sub load_credentials {
my ( $class, $config ) = @_;
return decode_json(
get( "http://
title' => ['meta[property="og:title"]', 'meta[name="twitter:title"]', 'title'],
);
my @JSON_ATTRS = (
'author_name', 'author_url', 'cache_age', 'height', 'provider_name', 'p
O_JSON {
my $self = shift;
my %json;
for my $attr (grep { defined $self->$_ } @JSON_ATTRS) {
$json{$attr} = $self->$attr;
$json{$attr} = "$json{$attr}" if $attr =~ /url$/;
}
$json{
html} = $self->html unless $self->type eq 'link';
return \%json;
}
sub _dump { Mojo::Util::dumper($_[0]->TO_JSON); }
sub _el {
my ($self, $dom, @sel) = @_;
@sel = @{$DOM_SEL{$sel[0]}} if $DOM
package LinkEmbedder;
use Mojo::Base -base;
use LinkEmbedder::Link;
use Mojo::JSON;
use Mojo::Loader 'load_class';
use Mojo::Promise;
use Mojo::UserAgent;
use constant TLS => eval { require IO::Sock
rve {
my ($self, $c, $args) = @_;
my $format = $c->stash('format') || $c->param('format') || 'json';
my $log_level;
$args ||= {url => $c->param('url')};
$log_level = delete $args->{log_leve
>html) if $format eq 'html';
my $json = $err ? {err => $err->{code} || 500} : $link->TO_JSON;
return $c->render(json => $json) unless $format eq 'jsonp';
my $name = $c->param('callback
package Dist::Zilla::Plugin::CSJEWELL::ReleaseStatusFromMetaJSON;
our $VERSION = v0.001;
use v5.10;
use JSON::MaybeXS qw();
use Moose;
with 'Dist::Zilla::Role::ReleaseStatusProvider';
sub provide_r
_status {
my ($self) = @_;
my ($file) = grep { $_->name eq 'META.json' } @{ $self->zilla->files };
my $ref = JSON::MaybeXS->new()->utf8->decode($file->encoded_content);
my $status
END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Plugin::CSJEWELL::JSONReleaseStatus - Set release status from META.json
=head1 VERSION
version 0.994
=for Pod::Coverage provide_release_statu
scription($text);
last;
}
}
sub _parse_gist {
my ($self, $tx) = @_;
$self->_learn_from_json($tx);
return $self unless $self->{files};
return $self->type('rich')->template([__PACKAGE__,
ncoding UTF-8
=head1 NAME
JSON::Create - Create JSON
=head1 SYNOPSIS
use JSON::Create 'create_json';
my %hash = (a => 'b', c => 'd');
print create_json (\%hash);
produces o
is.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Create-0.35/examples/synopsis.pl> in the distribution.)
=head1 VERSION
This document describes JSON::Create version 0.35,
corresponding to L<git
k/json-create/commit/ffe5ce4b3304dac8f668133563a276f831966bbe> at Fri Jul 16 07:42:12 2021 +0900.
=head1 DESCRIPTION
JSON::Create encodes Perl variables into JSON. The basic routine
L</create_json>
package LinkEmbedder::Link::Basic;
use Mojo::Base 'LinkEmbedder::Link';
use Mojo::JSON;
use Mojo::Util 'trim';
my $PHOTO_RE = qr!\.(?:jpg|png|gif|webp)\b!i;
my $VIDEO_RE = qr!\.(?:mpg|mpeg|mov|mp4|o
elf->SUPER::_learn_from_dom($dom);
$tmp = $dom->at('script[type="application/ld+json"]');
$self->_learn_from_json_schema($tmp->text) if $tmp;
# Bitbucket hack
$tmp = $dom->at('div.codehilite
earn_from_json_schema {
my ($self, $json) = @_;
eval { $json = Mojo::JSON::from_json($json) } unless ref $json eq 'HASH';
return unless ref $json eq 'HASH'
ay->[0];
# Or HTTP check
return $self->app->ua->post($url => json => {user => $name, pass => $pass})
->res->tx->json('/result');
}
1;
Model Users-Client
package MyApp::Model::U
r %API = (
'ted.com' => 'https://www.ted.com/services/v1/oembed.json',
'vimeo.com' => 'https://vimeo.com/api/oembed.json',
'youtube.com' => 'https://www.youtube.com/oembed',
'youtu.be'
my $api_url = $self->_api_url;
return $self->_get_p($api_url)->then(sub { $self->_learn_from_json(shift) }) if $api_url;
$self->error({message => "Unknown oEmbed provider for @{[$self->url]}",
_from_json(shift) });
}
sub _learn_from_json {
my ($self, $tx) = @_;
my $json = $tx->res->json;
$self->type('rich');
if (my $description = $json->{message}) {
$description = "$json->{au
on" if $json->{author_name};
$self->description($description);
}
if ($json->{finished_at}) {
$self->title(sprintf 'Build %s at %s', $json->{status} ? 'failed' : 'succeeded', $json->{finis
hed_at});
}
elsif ($json->{started_at}) {
$self->title(sprintf 'Started building at %s.', $json->{started_at});
}
else {
$self->title('Build has not been started.');
}
return $sel
#!/usr/bin/env perl
# Benchmark JSON::Create against JSON::XS.
use warnings;
use strict;
use utf8;
use FindBin '$Bin';
use Time::HiRes;
use Text::Table::Tiny 'generate_table';
use Getopt::Long;
my
ib '/home/ben/projects/json-create/blib/lib';
use lib '/home/ben/projects/json-create/blib/arch';
# Contenders
use JSON::Create 'create_json';
use JSON::XS ();
use Cpanel::JSON::XS ();
# Number of
$count = 100;
$times = 20;
}
print "Versions used:\n";
my @modules = qw/Cpanel::JSON::XS JSON::Create JSON::XS/;
my @mvp;
for my $module (@modules) {
my $abbrev = $module;
$abbrev =~ s/
/* XS part of JSON::Create. */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <stdint.h>
#include "unicode.h"
#include "qsort-r.c"
#include "json-create-perl.c"
\
json_create_status_t jcs; \
jcs = x; \
if (jcs != json_create_ok) { \
warn ("%s:%d: bad status %d from %s", \
__FILE__, __LINE__, jcs, #x); \
} \
}
typedef json_cre
ate_t * JSON__Create;
#define JCSET \
if (items > 1) { \
if ((items - 1) % 2 != 0) { \
warn ("odd number of arguments ignored"); \
} \
else { \
int i; \
package WWW::Correios::CEP;
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
our $VERSION = 1.044;
use Encode;
use utf8;
sub new {
my ( $class, $params ) = @_;
my $this = {
k the outcome of the response
if ( $res->is_success ) {
$this->_parseJSON( \@result, $res->content, $as_html_tree );
}
else {
$resu
turn wantarray ? @result : $result[0];
}
sub _parseJSON {
my ( $this, $address_ref, $json, $as_html_tree ) = @_;
my $obj = from_json($json);
for my $p ( @{ $obj->{dados} || [] } ) {
package API::INSEE::Sirene;
use strict;
use warnings;
use Carp 'croak';
use JSON;
use HTTP::Request::Common qw/ GET POST /;
use HTTP::Status ':constants';
use List::Util 'any';
use LWP::UserAgent;
u
PI::INSEE::Sirene V$VERSION");
$self->{'user_agent'}->default_header('Accept' => 'application/json');
}
sub _getToken {
my $self = shift;
croak 'Please provide your credentials.' if !def
self->{'user_agent'}->request($request);
my $json_obj;
if ($response->content_type =~ m/^application\/json/) {
$json_obj = decode_json($response->content);
}
else {
re
erlfunc entries in JSON format for the DHTML autocompleter
my @funcs = map {$_->title} grep {$_->content =~ /\S/} $self->perlfunc_items;
s|[/\s(].*||s foreach @funcs;
my $json_funcs = "[" . join
(",", map {qq{"$_"}} uniq @funcs) . "]";
# perlvar entries in JSON format for the DHTML autocompleter
my @vars = map {$_->title} grep {!/->/} map {@$_} $self->perlvar_items;
s|\s*X<.*||s foreac
h @vars;
s|\\|\\\\|g foreach @vars;
s|"|\\"|g foreach @vars;
my $json_vars = "[" . join(",", map {qq{"$_"}} uniq @vars) . "]";
# initial sections : perldocs, pragmas and scripts
my @per