BICConnectInfo DBICHashRef/;
use MooseX::Types::JSON qw(JSON);
use MooseX::Types::Path::Class qw(Dir File);
use Try::Tiny;
use JSON::Any qw(DWIW XS JSON);
use namespace::autoclean;
=head1 NAME
DBIx:
ash ref or json string to be used for identifying data to manipulate
=cut
has 'where' => (
is => 'rw',
isa => DBICHashRef,
coerce => 1,
);
=head2 set
a hash ref or json string to
> (
is => 'rw',
isa => DBICHashRef,
coerce => 1,
);
=head2 attrs
a hash ref or json string to be used for passing additional info to the ->search call
=cut
has 'attrs' => (
is
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) },
}
f ($response->content_type =~ m'^(application/rdf\+xml|(application|text)/(x-)?(rdf\+)?(turtle|n3|json))'i)
{
if (uc $response->request->method ne 'GET')
{
$self->_ua->max_redirect(3);
$res
le';
$type = 'RDFXML' if $response->content_type =~ /rdf.xml/;
$type = 'RDFJSON' if $response->content_type =~ /json/;
}
else
{
return ($response, undef);
}
$response->is_success or retu
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
Loading L<MooseX::Attribute::Deflator::Moose>
will cause HashRefs and ArrayRefs to be encoded as JSON strings. However, you can simply overwrite
those deflators (and inflators) to deflate to somethin
C<benchmark.pl> tests three ways of deflating the value of a HashRef attribute
to a json encoded string (using L<JSON>).
my $obj = MyBenchmark->new( hashref => { foo => 'bar' } );
my $attr =
ate($obj);
Using the deflate attribute method, supplied by this module.
=item accessor
JSON::encode_json($obj->hashref);
If the attribute comes with an accessor, you can use this
method, to defl
BIx::Class administrative library
=over
=item * JSON::Any >= 1.22
=item * Moose >= 0.98
=item * MooseX::Types >= 0.21
=item * MooseX::Types::JSON >= 0.02
=item * MooseX::Types::Path::Class >= 0.
tem * Getopt::Long::Descriptive >= 0.081
=item * JSON::Any >= 1.22
=item * Moose >= 0.98
=item * MooseX::Types >= 0.21
=item * MooseX::Types::JSON >= 0.02
=item * MooseX::Types::Path::Class >= 0.
,
'morph without arguments prints json'
);
$result = qx(bin/morph /foo/bar);
like(
$result,
qr/^(5|"5")\n$/,
'morph without arguments prints json'
);
$result = qx(bin/morph --format=
=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
=
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;
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;
$r{$disk}{count} = Yars::Tools->count_files($disk) if $count;
}
return $c->render_json(\%r) unless $c->param('all');
my %all = ( Yars::Tools->server_url => \%r );
for my $serve
$all{$server} = $res->json;
}
return $c->render_json(\%all);
};
=head2 POST /disk/status
Mark disks up or down. Send the disk root and state (up or down)
as JSON encoded in the body.
=c
);
}
$c->render_text($success ? "ok" : "failed" );
};
=head2 POST /check/manifest
Given JSON with 'manifest' which is a return-delimited string
of filenames and md5s (like the output of md5s
se Data::Dumper;
use Try::Tiny;
use File::Path qw/mkpath/;
use File::Temp;
use File::Compare;
use JSON::XS;
use File::stat qw/stat/;
use Mojo::ByteStream qw/b/;
use strict;
use warnings;
our %Bucket2
tateFile;
return $cached if $mod_time && $mod_time == stat($StateFile)->mtime;
our $j ||= JSON::XS->new;
-e $StateFile or LOGDIE "Missing state file $StateFile";
$cached = $j->decode(M
{
my $class = shift;
my $state = shift;
my $dir = dirname($StateFile);
our $j ||= JSON::XS->new;
mkpath $dir;
my $temp = File::Temp->new(DIR => $dir, UNLINK => 0);
print $t
ers + hosts to buckets for yars.
our $VERSION = '1.33'; # VERSION
use strict;
use warnings;
use JSON::MaybeXS ();
use Getopt::Long qw( GetOptions );
use Pod::Usage qw( pod2usage );
use feature 'say'
$_, buckets => $servers{$host}{$_} }, keys %{ $servers{$host} }
]};
}
my $out = JSON::MaybeXS->new->space_after->encode({ servers => \@conf });
$out =~ s/{/\n{/g;
$out =~ s/\
EST-y subclass of Catalyst::Request
=head1 SYNOPSIS
if ( $c->request->accepts('application/json') ) {
...
}
my $types = $c->request->accepted_content_types();
=head1 DESCRI
ware, licensed under:
#
# The (three-clause) BSD License
#
package MyBenchmark;
use Moose;
use JSON;
use DateTime;
use MooseX::Attribute::Deflator::Moose;
use MooseX::Attribute::Deflator;
has has
flator'],
default => sub { { foo => 'bar' } }
);
package main;
use strict;
use warnings;
use JSON;
use Benchmark qw(:all);
my $obj = MyBenchmark->new;
my $attr = $obj->meta->get_attribute('hash
> sub {
$attr->deflate($obj);
},
get_value => sub {
JSON::encode_json( $attr->get_value( $obj, 'hashref' ) );
},
accessor => sub {
m
ia Type" error. What gives?!
A: Most likely, you haven't set Content-type equal to "application/json", or
one of the accepted return formats. You can do this by setting it in your query
accepted re
mats. You can do this by setting it in your query string
thusly: C<< ?content-type=application%2Fjson (where %2F == / uri escaped). >>
B<NOTE> Apache will refuse %2F unless configured otherwise.
Mak
get($bucket_map_url);
if(my $res = $tx->success)
{
my %server_bucket_map = %{ $res->json };
my %my_bucket_map = %{ $yars->tools->bucket_map };
foreach my $key (keys %m
e JSON::XS ();
use constant DEFAULT_CHARSET => 'utf-8';
my $json = undef;
sub _default_formatter {
my $value = shift;
$json ||= JSON::XS->new->allow_nonref->allow_blessed;
return $json-
value ), returns JavaScript representation for the value.
JSON::XS-based by default.
* charset - Charset, utf-8 by default.
=cut
sub new {
my ( $cl
package Catalyst::Action::Serialize::JSONP;
use Moose;
use namespace::autoclean;
extends 'Catalyst::Action::Serialize::JSON';
our $VERSION = '1.06';
$VERSION = eval $VERSION;
after 'execute' => sub
.$c->res->output().');');
} else {
warn 'Callback: '.$callback_value.' will not generate valid Javascript. Falling back to JSON output';
}
}
};
__PACKAGE__->meta->make_immutable;
1;
# cope with invalid (missing required q parameter) header like:
# application/json; charset="utf-8"
# http://tools.ietf.org/html/rfc2616#section-14.1
unless
ing it REST methods and attributes.
=head1 SYNOPSIS
if ( $c->request->accepts('application/json') ) {
...
}
my $types = $c->request->accepted_content_types();
=head1 DESCRI