arp about old text/x-json
if ($content_type eq 'text/x-json') {
$c->log->info('Using deprecated text/x-json content-type.');
$c->log->info('Use application/json instead!');
}
=item L<CPAN::Indexer::Mirror>
Write mirror.yml and mirror.json
=item L<File::Rsync::Mirror::Recentfile>
Read and write RECENT-XX.json files
=item L<Parse::CPAN::MirroredBy>
Read MIRRORED.BY
=
ttyTrace - Pretty Tracing DebugObj
=head1 SYNOPSIS
DBIC_TRACE_PROFILE=~/dbic.json perl -Ilib ./foo.pl
Where dbic.json contains:
{
"profile":"console",
"show_progress":1,
"squash_repeats
rdf_statement' };
use File::ShareDir qw[];
use File::Spec qw[];
use Set::Scalar;
use JSON qw[decode_json encode_json];
use Scalar::Util qw[looks_like_number blessed];
our $VERSION = '0.053';
use RDF
);
mkdir $jpdir unless -d $jpdir;
my $json_path = File::Spec->catfile(
File::Spec->tmpdir,
'RDF-RDFa-Linter',
'schemaorg.json',
);
my $owl_path = File::ShareDir
if (-f $json_path)
{
my @json_stat = stat $json_path;
my @owl_stat = stat $owl_path;
if ($json_stat[9] >= $owl_stat[9]) # if JSON as uptodate as OWL
{
open my $fh, '<', $json_path;
package Rex::Endpoint::HTTP::Fs;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON;
use Mojo::Upload;
use Data::Dumper;
use MIME::Base64;
use Rex::Endpoint::HTTP::Interface::Fs;
# This actio
lf->_iface->ls($self->_path);
$self->render_json({ok => Mojo::JSON->true, ls => \@ret});
} or do {
$self->render_json({ok => Mojo::JSON->false});
};
}
sub is_dir {
my $self = shi
lf->_iface->is_dir($self->_path)) {
$self->render_json({ok => Mojo::JSON->true});
}
else {
$self->render_json({ok => Mojo::JSON->false});
}
}
sub is_file {
my $self = shift;
package Rex::Endpoint::HTTP::Base;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON;
# This action will render a template
sub index {
my $self = shift;
$self->render_text("Rex::Endpoi
:Controller';
use Mojo::JSON;
use Rex::Endpoint::HTTP::Interface::Exec;
# This action will render a template
sub index {
my $self = shift;
my $ref = $self->req->json;
my $cmd = $ref->{exe
};
if($@) {
return $self->render_json({ok => Mojo::JSON->false, output => "$@", retval => 1});
}
$self->render_json({ok => Mojo::JSON->true, output => $out, retval => $?});
}
1;
:JSON;
use Win32::API;
use Rex::Endpoint::HTTP::Interface::System;
sub free {
my $self = shift;
my $memory_info = $self->_iface->get_memory_statistics;
$self->render_json({ok => Mojo::JSON-
_json({ok => Mojo::JSON->true, max => $memory_info->{swap_size}});
}
sub used {
my $self = shift;
my $memory_info = $self->_iface->get_memory_statistics;
$self->render_json({ok => Mojo::JSON
,
sub {
my $self = shift;
my $client = $self->client;
$client->GET( sprintf( '/images/%s.json', $self->id ) );
my $data = $client->process_response(404 => sub {
return { is_available =>
milar {
my $self = shift;
my $client = $self->client;
$client->GET(sprintf('/images/%s/similar.json', $self->id));
my $images = $client->process_response;
return [ map { $self->new_with_client( '
a proxy class for the data returned from a URL
like L<http://api.shutterstock.com/images/15484942.json>. Please look
at that data structure for a better idea of exactly what each of the attributes
in
s generated automatically by calling _gen_pod from the
# Makefile.PL in $AUTHOR mode
my $json_any = {
'JSON::Any' => '1.22',
};
my $moose_basic = {
'Moose'
%$moose_basic,
};
my $admin_basic = {
%$moose_basic,
%$json_any,
'MooseX::Types::Path::Class' => '0.05',
'MooseX::Types::JSON' => '0.02',
'namespace::autoclean' => '
=> {
'Test::EOL' => '1.0',
},
},
test_prettydebug => {
req => $json_any,
},
test_leaks => {
req => {
'Test::Memory::Cycle' => '0',
'Devel:
:JSON;
use Win32::API;
use Rex::Endpoint::HTTP::Interface::System;
sub free {
my $self = shift;
my $memory_info = $self->_iface->get_memory_statistics;
$self->render_json({ok => Mojo::JSON-
>render_json({ok => Mojo::JSON->true, max => $memory_info->{total_memory}});
}
sub used {
my $self = shift;
my $memory_info = $self->_iface->get_memory_statistics;
$self->render_json({ok =>
ild__results_data {
my $self = shift;
my $client = $self->client;
$client->GET('/images/search.json', $self->query);
return $client->process_response;
}
sub page { return shift->_results_
jolicious::Controller';
use Mojo::JSON;
use MIME::Base64;
use Rex::Endpoint::HTTP::Interface::File;
sub open {
my $self = shift;
my $ref = $self->req->json;
eval {
$self->_iface->o
$self->render_json({ok => Mojo::JSON->true});
} or do {
$self->render_json({ok => Mojo::JSON->false});
};
}
sub read {
my $self = shift;
my $ref = $self->req->json;
my $fi
($file, $start, $len);
$self->render_json({ok => Mojo::JSON->true, buf => encode_base64($buf)});
} or do {
$self->render_json({ok => Mojo::JSON->false});
};
}
# this seems odd, but
m .. store JSON/YAML in a column and have it deflate/inflate automatically?
You can use L<DBIx::Class::InflateColumn> to accomplish YAML/JSON storage transparently.
If you want to use JSON, then in
lowing:
use JSON;
__PACKAGE__->add_columns(qw/ ... my_column ../)
__PACKAGE__->inflate_column('my_column', {
inflate => sub { jsonToObj(shift) },
deflate => sub { objToJson(shift) },
}
header && $header eq 'XMLHttpRequest' ) {
$self->app->log->debug( "AJAX / JSON Response triggered!" );
$self->render_json({
dyncontent => $self->stash( 'content' ),
headline => $self->stash(
IS
tracks.pm :
package Tracks;
use Clustericious::Client;
route 'mixes' => '/mixes.json';
route_doc mixes => 'Get a list of mixes.';
route_args mixes => [
{ name => 'api
to
a data structure if it is application/json.
=cut
use Mojo::Base qw/-base/;
use Mojo::UserAgent;
use Mojo::ByteStream qw/b/;
use Mojo::Parameters;
use JSON::XS;
use Clustericious::Config;
use Clu
erence is passed, the method changes to POST and the hash is
encoded into the body as application/json.
=item modifies_payload, key
Describes how the parameter modifies the payload.
'hash' means se
Save access token to session and re-direct to admin page
$self->session->{access_token} = $res->json->{access_token};
$self->redirect_to('/admin');
}
else {
# Authentication or OAuth2 failure,
subscription for a specific Shutterstock customer
use strict;
use warnings;
use Moo;
use JSON qw(encode_json);
use WebService::Shutterstock::LicensedImage;
use Carp qw(croak);
with 'WebService::Shu
::HTTP::Login;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON;
# This action will render a template
sub index {
my $self = shift;
$self->render_json({ok => Mojo::JSON->true});
}
1;
pes::JSON qw(JSON);
subtype DBICArrayRef,
as ArrayRef;
subtype DBICHashRef,
as HashRef;
coerce DBICArrayRef,
from JSON,
via { _json_to_data ($_) };
coerce DBICHashRef,
from JSON,
v
_json_to_data($_) };
subtype DBICConnectInfo,
as ArrayRef;
coerce DBICConnectInfo,
from JSON,
via { return _json_to_data($_) } ;
coerce DBICConnectInfo,
from Str,
via { return _json_t
via { [ $_ ] };
sub _json_to_data {
my ($json_str) = @_;
my $json = JSON::Any->new(allow_barekey => 1, allow_singlequote => 1, relaxed=>1);
my $ret = $json->jsonToObj($json_str);
return $ret;