ge Plack::ResponseHelper::JSON;
use strict;
use warnings;
use JSON;
use Plack::Response;
sub helper {
return sub {
my $r = shift;
my $body = encode_json $r;
my $response
->content_type('application/json; charset=utf-8');
$response->body($body);
return $response;
};
}
1;
__END__
=head1 NAME
Plack::ResponseHelper::JSON
=head1 SEE ALSO
Plack::Re
package JSON::Streaming::Writer;
use strict;
use warnings;
use IO::File;
use Carp;
use B;
use constant ROOT_STATE => {};
our $VERSION = '0.03';
sub for_stream {
my ($class, $fh) = @_;
my
);
my $state = $self->_push_state();
$state->{in_property} = 1;
$self->_print($self->_json_string($name), ":");
}
sub end_property {
my ($self) = @_;
Carp::croak("Can't end_prope
) unless $self->_can_start_simple_value;
$self->_make_separator();
$self->_print($self->_json_string($value));
$self->_state->{made_value} = 1;
}
sub add_number {
my ($self, $value)
=head1 NAME
JSON::Streaming::Reader::EventWrapper - Internal utility package for JSON::Streaming::Reader
=cut
package JSON::Streaming::Reader::EventWrapper;
use strict;
use warnings;
# Make a du
$offset, "^\n";
}
1;
=head1 DESCRIPTION
This package is an internal implementation detail of L<JSON::Streaming::Reader>. It is used
to provide an API that looks like it blocks on top of a handle th
cking handle.
Instances of this class support enough of the C<IO::Handle> interface to satisfy L<JSON::Streaming::Reader>
and no more. In other words, they support only the C<read> method and assume
=head1 NAME
JSON::Streaming::Reader - Read JSON strings in a streaming manner
=cut
package JSON::Streaming::Reader;
use strict;
use warnings;
use Carp;
use IO::Scalar;
use JSON::Streaming::Reader
or_stream($stream);
}
sub event_based {
my ($class, %callbacks) = @_;
my $fake_stream = JSON::Streaming::Reader::EventWrapper->new();
my $self = $class->for_stream($fake_stream);
$se
acter $char\n";
last;
}
};
if ($@) {
unless (ref($@) && $@ == JSON::Streaming::Reader::EventWrapper::UNDERRUN()) {
$self->{errored} = 1;
my
JSON::Streaming::Reader::TestUtil - Utility functions for the JSON::Streaming::Reader test suite
=head1 DESCRIPTION
This package contains some utility functions for use in the test suite for L<JSON
::Streaming::Reader>.
It's not useful outside of this context.
=cut
package JSON::Streaming::Reader::TestUtil;
use JSON::Streaming::Reader;
use Test::More;
use base qw(Exporter);
our @EXPORT = qw(
($name, $input, $expected_tokens) = @_;
my $jsonw = JSON::Streaming::Reader->for_string($input);
my @tokens = ();
while (my $token = $jsonw->get_token()) {
push @tokens, $token;
age Cache::Memcached::AnyEvent::Serializer::JSON;
use strict;
use Module::Runtime ();
BEGIN {
my $backend;
foreach my $module (qw(JSON JSON::XS JSON::PP)) {
eval { Module::Runtime::req
"Could not find JSON backend module";
}
{
no strict 'refs';
*_encode_json = \&{"${backend}::encode_json"};
*_decode_json = \&{"${backend}::decode_json"};
}
}
sub
{$_[1]} = _encode_json(${$_[1]});
${$_[2]} = bytes::length(${$_[1]});
${$_[3]} |= Cache::Memcached::AnyEvent::F_SERIALIZE();
}
sub deserialize {
${$_[1]} = _decode_json(${$_[1]});
}
1;
package Webservice::InterMine::Parser::JSON::ResultRows;
=head1 NAME
Webservice::InterMine::Parser::JSON::ResultRows -
parse rows of JSON results into L<ResultRow>s
=head1 DESCRIPTION
One of the
pret results sent from
the webservice.
=cut
use Moose;
extends 'Webservice::InterMine::Parser::JSON';
use Webservice::InterMine::ResultRow;
use InterMine::Model::Types qw/PathList/;
has view => (
package Webservice::InterMine::Parser::JSON::ArrayRefs;
=head1 NAME
Webservice::InterMine::Parser::JSON::ArrayRefs -
parse rows of JSON results into array-refs
=head1 DESCRIPTION
One of the parse
pret results sent from
the webservice.
=cut
use Moose;
extends 'Webservice::InterMine::Parser::JSON';
=head1 IMPLEMENTED PROCESSOR METHODS
The following methods implement the Processor interface.
=head1 NAME
Webservice::InterMine::Parser::JSON::HashRefs -
parse rows of JSON results into hash-refs
=head1 DESCRIPTION
One of the parsers used to intepret results sent from
the webservice.
=cu
ebservice::InterMine::Parser::JSON::HashRefs;
use Moose;
extends 'Webservice::InterMine::Parser::JSON';
use InterMine::Model::Types qw(PathList);
=head1 ATTRIBUTES
=head2 view - The view used to se
package Webservice::InterMine::Parser::JSON;
=head1 NAME
Webservice::InterMine::Parser::JSON - parse rows of JSON results
=head1 DESCRIPTION
One of the parsers used to intepret results sent from
the webservice.
=cut
use Moose;
with 'Webservice::InterMine::Parser';
use JSON::XS;
use MooseX::Types::Moose qw(Str);
use InterMine::Model::Types qw(Model);
=head1 IMPLEMENTED PARSER METHODS
The
)
reports whether the header has been parsed yet.
Here, this reports whether the beginning of the JSON
object has been seen, and whether the results array
is open.
=item * parse_header($line)
Parse
package JSON::Hyper::Link;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.011';
use strict qw( subs vars );
sub new
{
my ($class, $self) = @_;
$self = +{ href => $self } unless ref $self;
1;
__END__
=head1 NAME
JSON::Hyper::Link - represents a link found in a JSON document
=head1 DESCRIPTION
This is a tiny object representng a hyperlink found in a JSON document.
You totally have
=head2 Constructor
Generally speaking you don't want to construct these. They're constructed
by JSON::Hyper's C<find_links> method and I can't think of any conceivable
reason why you'd want to const
package JSON::Hyper;
use 5.008;
use strict;
use JSON::Hyper::Link;
use Carp;
use JSON;
use JSON::Path;
use LWP::UserAgent;
use Scalar::Util qw[blessed];
use Storable qw[dclone];
use URI;
use URI::E
'cpan:TOBYINK';
our $VERSION = '0.011';
our $DEBUG = 0;
sub json_ref
{
return {
description => 'A hyper schema for the JSON referencing convention',
links => [
{
href => '{id}
ies => { '$ref' => '#' },
};
}
sub new
{
my ($class, $schema) = @_;
$schema ||= json_ref();
$schema = from_json($schema) unless ref $schema;
return bless { schema => $schema, ua => undef } => $c
package JSON::Types;
use strict;
use warnings;
use parent 'Exporter';
our $VERSION = '0.05';
our @EXPORT = qw/number string bool/;
sub number($) {
return undef unless defined $_[0];
$_[0] +
=head1 NAME
JSON::Types - variable type utility for JSON encoding
=head1 SYNOPSIS
# Export type functions by default
use JSON;
use JSON::Types;
print encode_json({
num
port interface
use JSON::Types ();
print encode_json({
number => JSON::Types::number "123",
string => JSON::Types::string 123,
bool => JSON::Types::bool "True va
package Tapper::Reports::Web::View::JSON;
our $AUTHORITY = 'cpan:TAPPER';
$Tapper::Reports::Web::View::JSON::VERSION = '5.0.17';
use strict;
use warnings;
use base qw/Catalyst::View/;
sub process {
plain');
if ( $or_c->stash->{content} ) {
$or_c->response->body(
JSON::XS::encode_json( $or_c->stash->{content} )
);
}
else {
$or_c->response->body('')
}
return 1;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Tapper::Reports::Web::View::JSON
=head1 AUTHORS
=over 4
=item *
AMD OSRC Tapper Team <tapper@amd64.org>
=item *
Tapper Team
::JSON;
use base 'WWW::Snooze::Serialize';
use strict;
use warnings;
sub new {
my $class = shift;
my %args = @_;
bless {
extension => 'json',
mime => 'application/json'
self, $input) = @_;
my $output = JSON->new->allow_nonref->encode($input);
return $output;
}
sub decode {
my ($self, $input) = @_;
my $output = JSON->new->allow_nonref->decode($input);
package Message::Passing::Filter::Encoder::JSON;
use Moo;
use MooX::Types::MooseLike::Base qw/ Bool /;
use JSON qw/ to_json /;
use Scalar::Util qw/ blessed /;
use Try::Tiny;
use Message::Passing::Exce
an('to_hash')) {
$message = $message->to_hash;
}
}
to_json( $message, { utf8 => 1, $self->pretty ? (pretty => 1) : () } )
}
catch {
$self->
:Role::Filter::Encoder::JSON - Encodes data structures as JSON for output
=head1 DESCRIPTION
This filter takes a hash ref or an object for a message, and serializes it to JSON.
Plain refs work as e
package Message::Passing::Filter::Decoder::JSON;
use Moo;
use JSON qw/ from_json /;
use Try::Tiny;
use Message::Passing::Exception::Decoding;
use namespace::clean -except => 'meta';
with qw/
Mess
/;
sub filter {
my ($self, $message) = @_;
try {
ref($message) ? $message : from_json( $message, { utf8 => 1 } )
}
catch {
$self->error->consume(Message::Passing::Exc
Passing::Role::Filter::Decoder::JSON
=head1 DESCRIPTION
Decodes string messages from JSON into data structures.
=head1 ATTRIBUTES
=head1 METHODS
=head2 filter
JSON decodes a message supplied as
use strict;
use warnings;
package Test::JSON::Entails;
{
$Test::JSON::Entails::VERSION = '0.2';
}
#ABSTRACT: Test whether one JSON or Perl structure entails/subsumes another
use base 'Test::Builde
r::Module';
our @EXPORT = qw(entails subsumes);
use Carp;
use JSON::Any;
use Scalar::Util qw(reftype);
my $JSON = JSON::Any->new;
sub entails ($$;$) {
my ($input, $entailed, $test_name) = @_;
$object= eval { $JSON->decode( $object ) };
if ( my $error = $@ ) {
$test->ok( 0, $test_name );
$test->diag("$item->[0] was not valid JSON");
package Data::Collector::Serializer::JSON;
{
$Data::Collector::Serializer::JSON::VERSION = '0.15';
}
# ABSTRACT: A JSON serializer for Data::Collector
use JSON;
use Moose;
use namespace::autoclean;
( $self, $data ) = @_;
return encode_json $data;
}
__PACKAGE__->meta->make_immutable;
1;
=pod
=head1 NAME
Data::Collector::Serializer::JSON - A JSON serializer for Data::Collector
=head1 V
ERSION
version 0.15
=head1 DESCRIPTION
Utilizes L<JSON>.
=head1 SUBROUTINES/METHODS
=head2 serialize
Gets data, serializes it and returns it.
=head1 AUTHOR
Sawyer X <xsawyerx@cpan.org>
=head1
nsored by socialflow.com
package JSON::Diffable;
use JSON ();
use Exporter 'import';
our $VERSION = '0.000001'; # 0.0.1
$VERSION = eval $VERSION;
my $real = JSON->new->relaxed->allow_nonref->utf8
;
our @EXPORT_OK = qw( encode_json decode_json );
sub encode_json {
my $data = shift;
return _encode($data, 0);
}
sub decode_json {
my $str = shift;
return $real->decode($str);
}
s
AME
JSON::Diffable - A relaxed and easy diffable JSON variant
=head1 SYNOPSIS
use JSON::Diffable qw( encode_json decode_json );
$json = encode_json $data;
$data = decode_json $json;
=