t;
my $method = shift || 'TO_JSON';
my $config = shift;
if (ref $method && ref $method ne 'CODE') {
$config = $method;
$method = 'TO_JSON';
}
return ext_parcel(
use JSON::MaybeXS;
use Web::Util::ExtPaging;
sub dispatch_request {
my $people_rs = get_rs();
sub (/people) {
[
200,
[ 'Content-type', 'application/json' ],
[ encode_json(ext_paginate($rs->search(undef, { rows => 25 }))) ],
]
},
sub (/people_lite) {
[
200,
[ 'Content-type', 'application/json' ],
[
ither;
use Smart::Args qw( args );
sub from_api {
args my $json => 'Either[Left[Str] | Right[Int]]';
$json->flat_map(sub {
# ...
});
}
from_api(right(1));
N = '0.004002';
use Carp qw(croak confess);
use Devel::Dwarn;
use Moo::Role;
requires 'decode_json';
requires 'request';
requires '_pre_update_resource_method';
around '_build_content_types_acc
pes = $self->$orig();
unshift @$types, { 'application/json' => 'from_activemodel_json' };
return $types;
};
sub from_activemodel_json {
my $self = shift;
$self->_pre_update_resource
_method( "_do_update_embedded_resources_activemodel" );
my $data = $self->decode_json( $self->request->content );
$self->update_resource($data, is_put_replace => 0);
return;
}
sub _do
code_json';
requires 'item';
around '_build_content_types_provided' => sub {
my $orig = shift;
my $self = shift;
my $types = $self->$orig();
unshift @$types, { 'application/json' =>
vemodel' };
return $types;
};
#sub to_json_as_activemodel { return $_[0]->encode_json($_[0]->render_item_as_activemodel_hash($_[0]->item)) }
sub to_json_as_activemodel {
my $self = shift;
# XXX this narrowing ought to be moved elsewhere
# it's a bad idea to be a side effect of to_json_as_activemodel
my @id_cols = $self->set->result_source->unique_constraint_columns( $self->id_
t;
use warnings FATAL => 'all';
use utf8;
use open qw(:std :utf8);
use Carp;
use HTTP::Tiny;
use JSON::PP;
use MIME::Base64;
sub new {
my ($class, @params) = @_;
croak "You should use new
nsport_security_state_static.json?format=TEXT';
my $base64_content = $self->_get_content_from_url( $url );
my $content = decode_base64 $base64_content;
my $json = $self->_get_data_without_
comments( $content );
my $data = decode_json $json;
return $data;
}
sub _get_data_without_comments {
my ($self, $data) = @_;
my $output;
foreach my $line (split /\n/, $data) {
:Data::Monad::Maybe;
use Smart::Args qw( args );
sub from_api {
args my $json => 'MaybeM[HashRef]';
$json->flat_map(sub {
# ...
});
}
from_api(just +{ ok => 1 });
from_ap
;
use Smart::Args qw( args );
sub maybe_value_from_api {
args my $json => 'MaybeM[HashRef]';
$json->flat_map(sub {
# ...
});
}
maybe_value_from_api(just +{
alue_from_api(nothing);
sub value_or_error_from_api {
args my $json => 'Either[Left[Str] | Right[Int]]';
$json->flat_map(sub {
# ...
});
}
value_or_error_from_a
e;
requires '_build_content_types_accepted';
requires 'render_item_into_body';
requires 'decode_json';
requires 'set';
requires 'prefetch';
around '_build_content_types_accepted' => sub {
my $
ication/json' => 'from_activemodel_json' };
return $types;
};
sub from_activemodel_json {
my $self = shift;
my $item = $self->create_resources_from_activemodel( $self->decode_json($self-
by any classes which consume this
role. It should take the contents of the template and return a JSON file as
described in L<Spreadsheet::Template>. This typically just means running it
through a tem
;
use Moose;
# ABSTRACT: generate spreadsheets from a template
use Class::Load 'load_class';
use JSON;
has processor_class => (
is => 'ro',
isa => 'Str',
default => 'Spreadshe
return $class->new($self->processor_options);
},
);
has json => (
is => 'ro',
default => sub {
return JSON->new;
}
);
sub _writer {
my $self = shift;
my $class
late, $vars);
# not decode_json, since we expect that we are already being handed a
# character string (decode_json also decodes utf8)
my $data = $self->json->decode($contents);
return
quest body within
# [START] and [END] tags
# request_body :
# [START]
# xml or json or form based
# [END]
################
#Set below values to configure the base URL for all te
e;
# ABSTRACT: create new templates from existing spreadsheets
use Class::Load 'load_class';
use JSON;
has parser_class => (
is => 'ro',
isa => 'Str',
default => 'Spreadsheet:
self = shift;
my ($filename) = @_;
my $data = $self->parser->parse($filename);
return JSON->new->pretty->canonical->encode($data);
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__EN
my $generator = Spreadsheet::Template::Generator->new;
open my $fh, '>:encoding(utf8)', 'out.json';
$fh->print($generator->generate($filename));
=head1 DESCRIPTION
This module is used to crea
Spreadsheet::Template::Helpers::Xslate::VERSION = '0.05';
use strict;
use warnings;
use JSON;
my $JSON = JSON->new;
use Sub::Exporter 'build_exporter';
my $import = build_exporter({
exports =>
$contents, $format, $type, %args) = @_;
$type = 'string' unless defined $type;
return $JSON->encode({
contents => "$contents",
format => _formats($package, $format),
$contents, $format, $type, %args) = @_;
$type = 'string' unless defined $type;
return $JSON->encode({
range => _parse_range($range),
contents => "$contents",
form
e::Generator::Parser::Excel::VERSION = '0.05';
use Moose::Role;
use DateTime::Format::Excel;
use JSON;
with 'Spreadsheet::Template::Generator::Parser';
requires '_create_workbook';
has _excel_dt =
'#ffffff'; # XXX
$format_data->{bold} = JSON::true
if $format->{Font}{Bold};
$format_data->{italic} = JSON::true
if $format->{Font}{Italic};
>{AlignV}}
unless $format->{AlignV} == 2;
$format_data->{text_wrap} = JSON::true
if $format->{Wrap};
}
if (!$format->{IgnoreNumberFormat}) {
}
$properties = {
map {
my $v = $properties->{$_};
$_ => JSON::is_bool($v) ? ($v ? 1 : 0)
: $_ eq 'left' ? $border{$v}
: $
ies->{pattern}}
unless $format_properties->{pattern} =~ /^\d+$/;
}
my $key = JSON->new->canonical->encode($format_properties);
if (exists $self->_formats->{$key}) {
re
SCRIPTION
This class implements L<Spreadsheet::Template::Processor>, and just passes
through the JSON data without modification.
=for Pod::Coverage process
=head1 AUTHOR
Jesse Luehrs <doy@tozt.n
right cell, or by an
Excel-style range (like C<A1:C3>).
=item true
Returns C<JSON::true>.
=item false
Returns C<JSON::false>.
=back
=head1 ATTRIBUTES
=head2 syntax
Which Xslate syntax engine
del::Role::DBIC::VERSION = '0.004002';
use Carp qw(croak confess);
use Devel::Dwarn;
use JSON::MaybeXS qw(JSON);
use Moo::Role;
requires 'get_url_for_item_relationship';
requires 'render_item_as_p
key = ($self->param('distinct')) ? 'data' : $self->activemodel_type;
my $top_doc = { # http://jsonapi.org/format/#document-structure-top-level
$top_set_key => $set_data,
};
if (ke
use Moo::Role;
use Carp qw(confess);
requires '_build_content_types_provided';
requires 'encode_json';
requires 'set';
requires 'render_activemodel_response';
requires 'activemodel_type';
around '
shift @$types, { 'application/json' => 'to_json_as_activemodel' };
return $types;
};
sub to_json_as_activemodel {
my $self = shift;
return $self->encode_json( $self->render_activemodel_r
_json';
requires 'render_item_as_plain_hash';
has content_types_provided => (
is => 'lazy',
);
sub _build_content_types_provided {
return [ { 'application/vnd.wapid+json' => 'to_plain_json'
} ]
}
sub to_plain_json { return $_[0]->encode_json($_[0]->render_set_as_plain($_[0]->set)) }
sub allowed_methods { return [ qw(GET HEAD) ] }
# Avoid complaints about $set:
## no critic (NamingConv
quests representing set resources, e.g.
the rows of a database table.
Supports the C<application/json> content type.
=head1 NAME
WebAPI::DBIC::Resource::Role::Set - methods related to handling requ