ge File::Serialize::Serializer::JSON::MaybeXS;
our $AUTHORITY = 'cpan:YANICK';
#ABSTRACT: JSON::MaybeXS serializer for File::Serialize
$File::Serialize::Serializer::JSON::MaybeXS::VERSION = '1.5.1';
u
{ qw/ json js / };
sub serialize {
my( $self, $data, $options ) = @_;
JSON::MaybeXS->new(%$options)->encode( $data);
}
sub deserialize {
my( $self, $data, $options ) = @_;
JSON::Mayb
le::Serialize::Serializer::JSON::MaybeXS - JSON::MaybeXS serializer for File::Serialize
=head1 VERSION
version 1.5.1
=head1 DESCRIPTION
=over
=item B<extensions>
C<json>, C<js>.
=item B<precede
package JSON::MaybeUTF8;
# ABSTRACT: Simple wrapper for explicit JSON Unicode text/UTF-8 byte functions
use strict;
use warnings;
our $VERSION = '2.000';
=head1 NAME
JSON::MaybeUTF8 - provide expl
icit text/UTF-8 JSON functions
=head1 SYNOPSIS
use JSON::MaybeUTF8 qw(:v1);
binmode STDOUT, ':encoding(UTF-8)';
binmode STDERR, ':raw';
(*STDOUT)->print(encode_json_text({ text => '...' }));
(*
TDERR)->print(encode_json_utf8({ text => '...' }));
=head1 DESCRIPTION
Combines L<JSON::MaybeXS> with L<Unicode::UTF8> to provide
4 functions that handle the combinations of JSON and UTF-8
encoding/
package Mojo::JSON_XS;
use strict;
use warnings;
our $VERSION = 1.022;
# From groups.google.com/forum/#!msg/mojolicious/a4jDdz-gTH0/Exs0-E1NgQEJ
use Cpanel::JSON::XS;
use Mojo::JSON;
use Mojo::Util
'monkey_patch';
my $Binary = Cpanel::JSON::XS->new->utf8;
my $Text = Cpanel::JSON::XS->new;
$_->canonical->allow_nonref->allow_unknown->allow_blessed->convert_blessed
->stringify_infnan->escape_s
onkey_patch 'Mojo::JSON', encode_json => sub { $Binary->encode(shift) };
monkey_patch 'Mojo::JSON', decode_json => sub { $Binary->decode(shift) };
monkey_patch 'Mojo::JSON', to_json => sub { $Text-
ckage Web::Request::Role::JSON;
# ABSTRACT: Make handling JSON easier in Web::Request
our $VERSION = '1.008'; # VERSION
use 5.010;
use MooseX::Role::Parameterized;
use JSON::MaybeXS;
use Encode;
p
ired => 0,
default => 'application/json; charset=utf-8',
);
role {
my $p = shift;
my $content_type = $p->content_type;
method json_payload => sub {
my $self = shi
encoding, which is utf8 for JSON. So $content has UTF8 flag
# on, which means we have to tell JSON::MaybeXS to turn
# utf8-handling OFF
return JSON::MaybeXS->new( utf8 => 0 )-
package JSON::Pointer::Extend;
use utf8;
use strict;
use warnings;
use JSON::Pointer;
use Carp qw();
our $VERSION = '0.02';
sub new {
my ($class, %opt) = @_;
my $self = {};
bless $self
ointer =~ /(.*?)\/\*(.+)?/) {
my $path = $1;
my $tail = $2;
my $arr_ref = JSON::Pointer->get($document, $path);
if (ref($arr_ref) ne 'ARRAY') {
Carp::croak(
$cb->($el, JSON::Pointer->get($document, $root_pointer), $field_name);
}
}
}
elsif ($pointer eq '') {
my $path = '';
my $arr_ref = JSON::Pointer->get($
JSON;
use strict;
use warnings;
use JSON;
use base 'Template::Flute::Iterator';
=head1 NAME
Template::Flute::Iterator::JSON - Iterator class for JSON strings and files
=head1 SYNOPSIS
$json
pg"}
]};
$json_iter = Template::Flute::Iterator::JSON->new($json);
$json_iter->next();
$json_iter_file = Template::Flute::Iterator::JSON->new(file => 'fruits.json');
=head1 DESCRIP
:Flute::Iterator::JSON is a subclass of L<Template::Flute::Iterator>.
=head1 CONSTRUCTOR
=head2 new
Creates an Template::Flute::Iterator::JSON object from a JSON string.
The JSON string can be eit
##
## File: DTA::CAB::Format::JSON.pm
## Author: Bryan Jurish <moocow@cpan.org>
## Description: Datum parser|formatter: YML code (generic)
package DTA::CAB::Format::JSON;
use DTA::CAB::Format;
use DT
A::CAB::Datum ':all';
use IO::File;
use JSON::XS;
use Carp;
use strict;
##==============================================================================
## Globals
##=================================
sterFormat(name=>__PACKAGE__, short=>'json-xs', filenameRegex=>qr/\.(?i:json(?:[\.\-\_]xs)?)$/);
DTA::CAB::Format->registerFormat(name=>__PACKAGE__, short=>'json');
}
##============================
::CAB::Analyzer::Dict::Json.pm
## Author: Bryan Jurish <moocow@cpan.org>
## Description: generic analysis dictionary API using JSON values
package DTA::CAB::Analyzer::Dict::Json;
use DTA::CAB::Analyz
er ':child';
use DTA::CAB::Analyzer::Dict;
use JSON::XS;
use IO::File;
use Carp;
use Encode qw(encode decode);
use strict;
##=========================================================================
me Options
## dictFile => $filename, ##-- filename (default=undef): should be TT-dict with JSON-encoded hash values
##
## ##-- Analysis Output
## label => $lab, ##-- analyzer
package Mojo::Response::JSON::Path;
# ABSTRACT: use JSON::Path for searching JSON responses
use Class::Method::Modifiers qw/install_modifier/;
use Mojo::Message;
use JSON::Path;
sub import {
my
hift;
install_modifier "Mojo::Message", 'around', 'json',
sub {
my $orig = shift;
my $self = shift;
if (@_) {
return JSON::Path->new($_[0])->value($orig->($self));
} else
package MojoX::JSON::RPC::Dispatcher::Method;
use Mojo::Base -base;
has id => undef;
has method => undef;
has params => undef;
has result => undef;
has is_not
rror( -32700, 'Parse error.', $msg );
}
sub response {
my ($self) = @_;
return {
jsonrpc => '2.0',
$self->is_notification ? () : ( id => $self->id ),
$self->has_error
NAME
MojoX::JSON::RPC::Dispatcher::Method - The data holder between RPC requests and responses.
=head1 SYNOPSIS
use MojoX::JSON::RPC::Dispatcher::Method;
my $meth = MojoX::JSON::RPC::Dispa
MojoX::JSON::RPC::Dispatcher;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON qw(decode_json);
use MojoX::JSON::RPC::Dispatcher::Method;
use MojoX::JSON::RPC::Service;
# process JSON-RPC ca
: q{}
)
);
$res->headers->content_type('application/json-rpc');
return $self->render(json => $rpc_response);
}
sub _acquire_methods {
my ($self) = @_;
my $log
st = decode_json( $req->body ); 1; } or $decode_error = $@;
if ( $decode_error ) {
$log->debug( 'REQUEST: JSON error> ' . $decode_error );
return MojoX::JSON::RPC::Disp
package MojoX::JSON::RPC;
use strict;
our $VERSION = '0.13';
1;
__END__
=head1 NAME
MojoX::JSON::RPC - a Perl implementation of the JSON-RPC 2.0 protocol for Mojolicious
=head1 SYNOPSIS
Server
lugin::JsonRpcDispatcher>):
#!/usr/bin/env perl
use Mojolicious::Lite;
use MojoX::JSON::RPC::Service;
plugin 'json_rpc_dispatcher' => {
services => {
'/jsonrpc' =
> MojoX::JSON::RPC::Service->new->register(
'sum',
sub {
my @params = @_;
my $sum = 0;
$sum += $_ for @pa
package MojoX::JSON::RPC::Service;
use Mojo::Base -base;
{
# Store rpc methods registered by register_rpc_method_names
my $_rpcs = undef;
sub new {
my $class = shift;
m
1;
__END__
=head1 NAME
MojoX::JSON::RPC::Service - JSON RPC Service registration
=head1 SYNOPSIS
use MojoX::JSON::RPC::Service;
my $svc = MojoX::JSON::RPC::Service->new;
$svc->re
'json_rpc_dispatcher',
services => {
'/jsonrpc' => $svc,
}
);
This package can also be used as a base class to make it easy to create object-oriented
JSON-RPC a
package MojoX::JSON::RPC::Client;
use Mojo::Base -base;
use Mojo::JSON qw(encode_json decode_json);
use Mojo::UserAgent;
has id => undef;
has ua => sub { Mojo::UserAgent->new };
e => 'application/json';
has tx => undef; # latest transaction
sub call {
my ( $self, $uri, $body, $callback ) = @_;
# body might be json already, only enc
ody : @{$body} ) {
$o->{version} ||= $self->version;
}
$body = encode_json($body);
}
else {
$body ||= q{};
}
# Always POST if $body is not empty!
ateColumn::JSON2Object;
# ABSTRACT: convert JSON columns to Perl objects
our $VERSION = '0.907'; # VERSION
use strict;
use warnings;
use 5.014;
use JSON::MaybeXS qw(encode_json decode_json );
use En
utf8::encode($raw_list) if utf8::is_utf8($raw_list);
my $list = decode_json($raw_list);
die('Can only work with arrayref')
unless
if !defined $data
|| $data =~ m/^\s*$/;
return decode_json( encode_utf8($data) );
},
deflate => sub {
my
package DBIx::Class::InflateColumn::JSON2Object::Role::Storable;
# ABSTRACT: simplified MooseX::Storage clone with enhanced JSON boolean handling
our $VERSION = '0.907'; # VERSION
use 5.014;
use Mo
ass::InflateColumn::JSON2Object::Trait::NoSerialize;
use JSON::MaybeXS;
use String::CamelCase qw(camelize decamelize);
use Moose::Util::TypeConstraints;
subtype 'InflateColumnJSONBool', as 'Ref';
co
via { $_ ? JSON->true : JSON->false };
coerce 'InflateColumnJSONBool',
from 'Int',
via { $_ ? JSON->true : JSON->false };
coerce 'InflateColumnJSONBool', from 'Undef', via { JSON->false };
package DBIx::Class::InflateColumn::JSON2Object::Trait::NoSerialize;
# ABSTRACT: NoSerialize trait for attributes
our $VERSION = '0.907'; # VERSION
use Moose::Role;
use 5.014;
package Moose::Meta::
'DBIx::Class::InflateColumn::JSON2Object::Trait::NoSerialize';
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
DBIx::Class::InflateColumn::JSON2Object::Trait::NoSerialize - NoSerial
ize trait for attributes
=head1 VERSION
version 0.907
=head1 NAME
DBIx::Class::InflateColumn::JSON2Object::Trait::NoSerialize - NoSerialize trait for attributes
=head1 VERSION
version 0.900
=he
package Data::Session::Serialize::JSON;
use parent 'Data::Session::Base';
no autovivification;
use strict;
use warnings;
use JSON;
our $VERSION = '1.18';
# ----------------------------------------
-------
sub freeze
{
my($self, $data) = @_;
return JSON -> new -> encode($data);
} # End of freeze.
# -----------------------------------------------
sub new
{
my($class) = @_;
return bless(
$data) = @_;
return JSON -> new -> decode($data);
} # End of thaw.
# -----------------------------------------------
1;
=pod
=head1 NAME
L<Data::Session::Serialize::JSON> - A persistent sessi
package Class::DBI::Plugin::TO_JSON;
###############################################################################
# Required inclusions.
###########################################################
###############################################
use base qw( Exporter );
our @EXPORT = qw(
TO_JSON
);
###############################################################################
# Version
#
# Subroutine: TO_JSON()
###############################################################################
# Turns the CDBI data record into a HASHREF suitable for use with 'JSON::XS'
###############
package Data::Serializer::JSON::MaybeXS;
use 5.008001;
use strict;
use warnings;
our $VERSION = '0.03';
BEGIN { @Data::Serializer::JSON::MaybeXS::ISA = qw(Data::Serializer) }
# This code was pretty
izer::JSON.
use JSON::MaybeXS qw();
use vars qw(@ISA);
sub json {
my ($self) = @_;
$self->{json} ||= JSON::MaybeXS->new(
%{ $self->{options} },
);
return $self->{json};
}
json->encode( $data );
}
sub deserialize {
my ($self, $json) = @_;
return $self->json->decode( $json );
}
1;
__END__
=head1 NAME
Data::Serializer::JSON::MaybeXS - Serialize data using JSON