package JSON::RPC::Simple::Client;
use strict;
use warnings;
use Carp qw(croak);
use LWP::UserAgent;
use JSON qw();
use URI::Escape qw();
require JSON::RPC::Simple;
use constant DEFAULT_TIMEOUT =>
180;
use constant JSON_RPC_HTTP_HEADERS => (
Content_Type => "application/json; charset=UTF-8",
Accept => 'application/json',
);
sub new {
my ($pkg, $uri, $attrs) = @
$attrs eq "HASH";
my $agent = delete $attrs->{agent} || "JSON::RPC::Simple " .
JSON::RPC::Simple->VERSION;
package YellowBot::API::Request::JSON;
{
$YellowBot::API::Request::JSON::VERSION = '0.96';
}
use Moose;
use HTTP::Request;
use JSON qw(encode_json);
use namespace::clean -except => 'meta';
exten
lf->_more_args;
# JSON POST request
my $req = HTTP::Request->new('POST', $uri, ['Content-Type' => 'application/json; charset=utf-8']);
my $req_content = encode_json(\%extra);
$req->co
ing utf8
=head1 NAME
YellowBot::API::Request::Json - Request object for YellowBot::API (JSON POST)
=head1 SYNOPSIS
This class manages setting up JSON POST requests for the YellowBot::API.
No user
package JSON::RPC::Simple::Dispatcher;
use strict;
use warnings;
use Carp qw(croak);
use HTTP::Response;
use JSON qw();
sub new {
my ($pkg, $args) = @_;
$args = {} unless ref $args eq "HAS
",
json => JSON->new->utf8,
error_handler => undef,
%$args,
target => {}
}, $pkg;
return $self;
}
sub json {
my $self = shift;
$self->{json} = shift i
f @_;
return $self->{json};
}
sub error_handler {
my $self = shift;
$self->{error_handler} = shift if @_;
return $self->{error_handler};
}
sub charset {
my $self = shift;
package JSON::RPC::Simple;
use strict;
use warnings;
use Scalar::Util qw(blessed refaddr);
use Carp qw(croak);
our $VERSION = '0.05';
our $ClientClass = "JSON::RPC::Simple::Client";
sub connect {
kg = shift;
require JSON::RPC::Simple::Client;
my $self = $ClientClass->new(@_);
return $self;
}
sub dispatch_to {
my $pkg = shift;
require JSON::RPC::Simple::Dispatche
return $method_attributes{refaddr $code};
}
my $method_attr_re = qr{
^
JSONRpcMethod
(?:\(\)|\(
\s*
(\w+ (\s*,\s* \w+)*)?
\s*
ge Grimlock::Web::View::JSON;
{
$Grimlock::Web::View::JSON::VERSION = '0.11';
}
use strict;
use base 'Catalyst::View::JSON';
use JSON::XS ();
use Try::Tiny;
sub encode_json {
my($self, $c, $da
ta) = @_;
my $encoder = JSON::XS->new->ascii->allow_nonref->convert_blessed->allow_blessed;
$encoder->pretty if $c->debug;
my $d = $encoder->encode($data);
return $d;
}
sub process {
lf->encode_json($c, $data);
return $serialized;
}
=head1 NAME
Grimlock::Web::View::JSON - Catalyst JSON View
=head1 SYNOPSIS
See L<Grimlock::Web>
=head1 DESCRIPTION
Catalyst JSON View.
=h
package Net::Fluidinfo::JSON;
use Moose;
use JSON::XS;
has json => (
is => 'ro',
isa => 'JSON::XS',
default => sub { JSON::XS->new->utf8->allow_nonref },
handles => [qw(enco
#========================================================================
#
# Badger::Codec::JSON
#
# DESCRIPTION
# Codec module for encoding/decoding Base64
#
# AUTHOR
# Andy Wardley <abw@wardl
ge Badger::Codec::JSON;
use Badger::Class
version => 0.01,
base => 'Badger::Codec',
import => 'class',
codecs => 'utf8';
eval "require JSON::XS";
our $HAS_JSON_XS = $@ ? 0 : 1;
eval "require JSON";
our $HAS_JSON = $@ ? 0 : 1;
our $MODULE =
$HAS_JSON_XS ? 'JSON::XS' :
$HAS_JSON ? 'JSON' :
die "No JSON implementation installed\n";
# TODO: figure out if it
package XML::XML2JSON;
use strict;
our $VERSION = '0.06';
use Carp;
use XML::LibXML;
our $XMLPARSER ||= XML::LibXML->new();
=head1 NAME
XML::XML2JSON - Convert XML into JSON (and back again) using
2JSON;
my $XML = '<test><element foo="bar"/></test>';
my $XML2JSON = XML::XML2JSON->new();
my $JSON = $XML2JSON->convert($XML);
print $JSON;
my $RestoredXML = $XML2JSON->json2xml($JSON)
sed Google for inspiration: http://code.google.com/apis/gdata/json.html
In short:
=over 4
=item * The response is represented as a JSON object; each nested element or attribute is represented as a
package Web::App::Presenter::JSON;
# $Id: JSON.pm,v 1.5 2009/03/29 10:08:42 apla Exp $
use Class::Easy;
use JSON;
use Web::App::Presenter;
use base qw(Web::App::Presenter);
1;
sub headers {
my $
ontent-Type' => 'text/plain; charset=utf-8');
# $headers->header ('Content-Type' => 'application/json');
$headers->header ('Cache-Control' => 'no-store');
# $headers->header ('Expires' => localtime
y $json = JSON->new;
$json->allow_blessed (1);
$json->convert_blessed (1);
$json->pretty (1);
$json->space_before (0);
$json->space_after (0);
my $json_text;
my $t = timer ('dumping json');
_JSON;
use 5.008002;
use strict;
use warnings;
use Carp;
our $VERSION = '0.05';
our (@ISA, @EXPORT_OK);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw( marc2marc_in_json
marc_in_json2marc each_record );
}
use MARC::Record;
use JSON; # decode_json()
#---------------------------------------------------------------------
sub marc2marc_in_json {
my( $marc_record )
= @_;
my %marc_in_json;
for my $leader ( $marc_record->leader() ) {
$marc_in_json{'leader'} = $leader;
}
for my $field ( $marc_record->fields() ) {
my $ftag = $fie
package App::Mimosa::Controller::JSON;
use Moose;
use Bio::Chado::Schema;
use File::Spec::Functions;
use Set::Scalar;
use Digest::SHA1 'sha1_hex';
use App::Mimosa::Util qw/slurp/;
use namespace::auto
json',
stash_key => 'rest',
'map' => {
# Work around an ExtJS bug that sends the wrong content-type
'text/html' => 'JSON',
}
);
sub grid_json :Path("/api/grid/json
.json") :ActionClass('REST') :Local { }
# Answer GET requests to the above Path
sub grid_json_GET {
my ( $self, $c ) = @_;
my $data = _grid_json_data($c);
# Return a 200 OK, with the dat
til::Json;
use Scalar::Util qw( blessed );
use Lucy qw( to_clownfish );
use Lucy::Util::StringHelper qw( utf8_valid utf8_flag_on );
use JSON::XS qw();
my $json_encoder = JSON::XS-
_json {
my ( undef, %args ) = @_;
my $result;
my $instream = $args{folder}->open_in( $args{path} )
or return;
my $len = $instream->length;
my $json;
$instream->read( $json, $len );
if ( utf8_valid($json) ) {
utf8_flag_on($json);
$result = eval { to_clownfish( $json_encoder->decode($json) ) };
}
IONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package Lucy::Util::Json;
use Lucy;
1;
__END__
a::Encoder::JSON;
use strict;
use warnings;
use JSON;
sub new {
my ($class, $args) = @_;
my $json = JSON->new;
$args ||= {};
for my $method (keys %$args) {
$json->$method(de
json => $json,
}, __PACKAGE__;
}
sub encode {
my ($self, $stuff, @args) = @_;
$self->{json}->encode($stuff, @args);
}
sub decode {
my ($self, $stuff, @args) = @_;
$self->{json}
rds
=head1 NAME
Data::Encoder::JSON - Data::Encoder gateway for JSON
=head1 SYNOPSIS
use Data::Encoder;
my $encoder = Data::Encoder->load('JSON');
my $json = $encoder->encode([qw/foo bar/
Silki::JSON;
{
$Silki::JSON::VERSION = '0.29';
}
use strict;
use warnings;
use JSON::XS;
{
my $json = JSON::XS->new();
$json->pretty(1);
$json->utf8(1);
sub Encode { $json->encod
) }
sub Decode { $json->decode( $_[1] ) }
}
1;
# ABSTRACT: A thin wrapper around a JSON::XS object
__END__
=pod
=head1 NAME
Silki::JSON - A thin wrapper around a JSON::XS object
=head1 VER
zer/JSON.pm
# ----------------------------------------------------------------------------------------------------------------------
package GX::Serializer::JSON;
use GX::Exception ();
use JSON ();
----
sub serialize {
my $self = shift;
my $data = shift;
my $string = eval { JSON::encode_json( $data ) };
if ( $@ ) {
GX::Exception->complain(
message =>
sub unserialize {
my $self = shift;
my $string = shift;
my $data = eval { JSON::decode_json( $string ) };
if ( $@ ) {
GX::Exception->complain(
message =
package JSON::YAJL;
use strict;
use warnings;
use JSON::YAJL::Generator;
use JSON::YAJL::Parser;
our $VERSION = '0.10';
1;
=head1 NAME
JSON::YAJL - An interface to the YAJL JSON parsing and generat
1 SYNOPSIS
use JSON::YAJL;
# see JSON::YAJL::Generator or JSON::YAJL::Parser
=head1 DESCRIPTION
YAJL is Yet Another JSON Library. YAJL is a small event-driven (SAX-style) JSON
parser written in
ng JSON generator, by Lloyd
Hilaiel. This module is a Perl interface to that library.
To find out more about YAJL, please visit http://lloyd.github.com/yajl/
For the generation library, see L<JSON::
package JSON::YAJL::Parser;
use strict;
use warnings;
our $VERSION = '0.10';
require XSLoader;
XSLoader::load( 'JSON::YAJL::Parser', $VERSION );
1;
=head1 NAME
JSON::YAJL::Parser - JSON parsing wi
th YAJL
=head1 SYNOPSIS
use JSON::YAJL;
my $text;
my $parser = JSON::YAJL::Parser->new(
0, 0,
[ sub { $text .= "null\n" },
sub { $text .= "bool: @_\n" },
unde
sub { $text .= "array_open\n" },
sub { $text .= "array_close\n" },
]
);
my $json
= '{"integer":123,"double":4,"number":3.141,"string":"a string","string2":"another string",
kage JSON::YAJL::Generator;
use strict;
use warnings;
our $VERSION = '0.10';
require XSLoader;
XSLoader::load( 'JSON::YAJL::Generator', $VERSION );
1;
=head1 NAME
JSON::YAJL::Generator - JSON gene
ration with YAJL
=head1 SYNOPSIS
use JSON::YAJL;
my $generator = JSON::YAJL::Generator->new();
# or to beautify (indent):
# my $generator = JSON::YAJL::Generator->new( 1, ' ' );
$genera
u to generate JSON with YAJL. This is quite a low-level
interface for generating JSON and it accumulates JSON in an internal buffer
until you fetch it.
If you create certain invalid JSON constructs t
:JSON;
use strict;
use warnings;
# ABSTRACT: A JSON converting processor
our $VERSION = '1.112100'; # VERSION
use Moose;
extends 'DataFlow::Proc::Converter';
use namespace::autoclean;
use JSON
r_opts
? JSON::Any->new( $self->converter_opts )
: JSON::Any->new;
},
handles => {
'json' => sub { shift->converter(@_) },
'json_opts' => sub {
converter_opts(@_) },
'has_json_opts' => sub { shift->has_converter_opts },
},
init_arg => 'json',
);
has '+converter_opts' => ( 'init_arg' => 'json_opts', );
sub _build_subs {
m