package Config::Any::JSON;
use strict;
use warnings;
use base 'Config::Any::Base';
=head1 NAME
Config::Any::JSON - Load JSON config files
=head1 DESCRIPTION
Loads JSON files. Example:
{
turn an array of valid extensions (C<json>, C<jsn>).
=cut
sub extensions {
return qw( json jsn );
}
=head2 load( $file )
Attempts to load C<$file> as a JSON file.
=cut
sub load {
my $cla
};
close $fh;
eval { require JSON::DWIW; };
unless( $@ ) {
my $decoder = JSON::DWIW->new;
my ( $data, $error ) = $decoder->from_json( $content );
die $error if $e
Plugin::JSON::Escape;
use strict;
use warnings;
use base qw/Template::Plugin/;
use JSON ();
our $VERSION = 0.02;
sub new {
my ($class, $context, $args) = @_;
my $self = bless { json => unde
$self->json_encode( @_ ) };
$context->define_vmethod( $_ => json => $encode ) for qw/hash list scalar/;
$context->define_filter( json => \&json_filter );
return $self;
}
sub json {
return $self->{json} if $self->{json};
my $json = JSON->new->allow_nonref;
my $args = $self->{args};
for ( keys %$args ) {
$json->$_( $args->{ $_ } ) if $json->can( $_ );
}
package HTML::Native::JSON;
# Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Gene
HTML::Native::JSON - embedded JSON data
=head1 SYNOPSIS
use HTML::Native::JSON;
my $json = HTML::Native::JSON->new ( {
start => 4,
end => 7
} );
print $json;
# print
s "<script type="application/json">{"start":4,"end":7}</script>"
=head1 DESCRIPTION
An L<HTML::Native::JSON> object represents a piece of inline JSON
data, usable by JavaScript code such as the jQue
package RINO::Client::Plugin::Json;
use strict;
require JSON;
sub write_out {
my $class = shift;
my $ref = shift;
my @array = @{$ref};
@array = splice(@array,1,$#array);
## fix
$a->{$k};
next unless($x);
my $h = eval { JSON::from_json($x) };
next if($@);
$a->{$k} = $h;
}
}
return JSON::to_json(\@array);
}
1;
:Format::json;
use Class::Easy;
use JSON;
sub new {
my $class = shift;
my $json = JSON->new;
$json->utf8 (1);
$json->pretty (1);
$json->convert_blessed (1);
bless {worker => $json}, $clas
package JSON::RPC::LWP;
BEGIN {
$JSON::RPC::LWP::VERSION = '0.006';
}
use 5.008;
use URI 1.58;
use LWP::UserAgent;
use JSON::RPC::Common;
use JSON::RPC::Common::Marshal::HTTP; # uses Moose
use Moos
d anyway
use JSON::RPC::Common::TypeConstraints qw(JSONValue);
subtype 'JSON.RPC.Version'
=> as 'Str'
=> where {
$_ eq '1.0' ||
$_ eq '1.1' ||
$_ eq '2.0'
};
coerce 'JSON.RPC.Version
= blessed($self) || $self;
no strict qw'vars refs';
if( $class eq __PACKAGE__ ){
return "JSON-RPC-LWP/$VERSION"
}else{
my $version = ${$class.'::VERSION'};
if( $version ){
ret
use strict;
use warnings;
package JSON::CPAN::Meta;
our $VERSION = '7.001';
=head1 NAME
JSON::CPAN::Meta - (deprecated) replace META.yml with META.json
=head1 DESCRIPTION
B<Achtung!> This library
will soon be obsolete as tools move to use the
official L<CPAN::Meta::Spec> JSON files.
CPAN distributions contain a file, F<META.yml>, which contains a description of
the distribution and its conte
y simple
and easily understood data format.
JSON, unlike YAML, is lacking in features but is extremely easy to parse and
generate correctly. Further, JSON documents are almost always valid YAML
docu
kage Memcached::Client::Serializer::JSON;
BEGIN {
$Memcached::Client::Serializer::JSON::VERSION = '2.01';
}
#ABSTRACT: Implements Memcached Serializing using JSON
use strict;
use warnings;
use Memc
ached::Client::Log qw{DEBUG LOG};
use JSON qw{decode_json encode_json};
use base qw{Memcached::Client::Serializer};
use constant F_JSON => 4;
sub deserialize {
my ($self, $data, $flags) = @_;
ss defined $data;
$flags ||= 0;
if ($flags & F_JSON) {
$self->log ("Deserializing data") if DEBUG;
$data = decode_json $data;
}
return $data;
}
sub serialize {
ozen_columns> but uses Data::Dumper mechanism.
=head2 add_json_columns ($data_column, @columns)
Same as L</add_frozen_columns> but uses JSON::XS mechanism.
=cut
sub add_frozen_columns {
my $th
columns => [@_],
});
}
sub add_json_columns {
shift->add_frozen_columns({
type => 'DBIx::Class::FrozenColumns::JSON',
data_column => shift,
columns
s || $this);
}
package DBIx::Class::FrozenColumns::JSON;
use base qw/DBIx::Class::FrozenColumns::Base/;
use strict;
use JSON::XS;
my $json = JSON::XS->new; #utf8 will be handled automatically (<dbt
----------------------------------+
#
# Apache2::WebApp::Plugin::JSON - JSON module wrapper
#
# DESCRIPTION
# Interface to the JSON (JavaScript Object Notation) encoder/decoder.
#
# AUTHOR
# Ma
--------------------------+
package Apache2::WebApp::Plugin::JSON;
use strict;
use warnings;
use base 'Apache2::WebApp::Plugin';
use JSON;
our $VERSION = 0.10;
#~~~~~~~~~~~~~~~~~~~~~~~~~~[ OBJECT
Return to the caller a new JSON object.
sub _init {
my ( $self, $params ) = @_;
return new JSON;
}
1;
__END__
=head1 NAME
Apache2::WebApp::Plugin::JSON - JSON module wrapper
=head1 SYNO
::JSON;
use Moose::Role;
use namespace::autoclean;
use JSON::Any;
use Try::Tiny;
our $VERSION = '0.01';
with 'Catalyst::TraitFor::Request::DecodedParams';
sub _build_params_decoder { return JSON::
m_json($value) }
catch { $decoder->from_json( $decoder->to_json($value) ) };
}
return $decoded_param;
}
1;
__END__
=head1 NAME
Catalyst::TraitFor::Request::DecodedParams::JSON
or;
__PACKAGE__->apply_request_class_roles(qw/
Catalyst::TraitFor::Request::DecodedParams::JSON
/);
=head1 AUTHOR & LICENSE
See L<Catalyst::TraitFor::Request::DecodedParams>.
=cut
age FlashVideo::JSON;
# Very simple JSON parser, loosely based on
# http://code.google.com/p/json-sans-eval
# Public domain.
use strict;
use base 'Exporter';
our @EXPORT = qw(from_json);
my $number
^\0-\x08\x0a-\x1f\"\\]|\\(?:["/\\bfnrt]|u[0-9A-Fa-f]{4}))};
my $string = qr{(?:"$oneChar*")};
my $jsonToken = qr{(?:false|true|null|[\{\}\[\]]|$number|$string)};
my $escapeSequence = qr{\\(?:([^u])|u(
'f' => "\f",
'n' => "\xA",
'r' => "\xD",
't' => "\t"
);
sub from_json {
my($in) = @_;
my @tokens = $in =~ /$jsonToken/go;
my $result = $tokens[0] eq '{' ? {} : [];
# Handle something
kage JSON::PP::Compat5005;
use 5.005;
use strict;
BEGIN {
if ( $] >= 5.006 ) {
require Carp;
die( "JSON::PP::Compat5005 is for Perl 5.005" );
}
}
my @properties;
$JSON::PP:
JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii;
*JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1;
*JSON::PP::JSON_PP_decode_surrogates = \&_decode_surrogates;
*JSON::PP::JSON
alid escaped unicode");
}
return pack('B*', $utf8bit);
}
sub JSON::PP::incr_text {
$_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new;
if ( $_[0]->{_incr_parser}->{incr_parsing} )
ckage JSON::PP::Compat5006;
use 5.006;
use strict;
BEGIN {
if ( $] >= 5.008 ) {
require Carp;
die( "JSON::PP::Compat5006 is for Perl 5.6" );
}
}
my @properties;
$JSON::PP::
JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii;
*JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1;
*JSON::PP::JSON_PP_decode_surrogates = \&JSON::PP::_decode_surrogates;
*JSON
::PP::JSON_PP_decode_unicode = \&JSON::PP::_decode_unicode;
unless ( defined &B::SVp_NOK ) { # missing in B module.
eval q{ sub B::SVp_NOK () { 0x02000000; } };
}
}
sub _encode
package Apache2::REST::Writer::json ;
use strict ;
use JSON::XS ;
use Data::Dumper ;
=head1 NAME
Apache2::REST::Writer::json - Apache2::REST::Response Writer for json
=cut
=head2 new
=cut
sub
ication/json' ;
}
=head2 asBytes
Returns the response as json UTF8 bytes for output.
=cut
sub asBytes{
my ($self, $resp ) = @_ ;
#Shallow unblessed copy of response
# JSON wont o
utput blessed object not implementing the TO_JSON request
my %resp = %$resp ;
my $coder = JSON::XS->new->allow_blessed(0)->utf8;
## These are bytes. This is correct.
return $coder->enc
ME
JSON::DWIW::Boolean - Return a true or false value when evaluated
in boolean context -- to be used with JSON::DWIW->encode() to
explicitly specify a boolean value.`
=head1 SYNOPSIS
use JSON::DW
IW;
my $val1 = JSON::DWIW->true;
my $val2 = JSON::DWIW->false;
# or
use JSON::DWIW::Boolean;
my $val1 = JSON::DWIW::Boolean->new(1); # true value
my $val2 = JSON::DWIW::Boolean->new(0); # fa
of L<JSON::DWIW> to specify that a true or false
value should be output when converting to JSON, since Perl does
not have explicit values for true and false.
Overloading is used, so if a L<JSON::DWI
ME
JSON::DWIW - JSON converter that Does What I Want
=head1 SYNOPSIS
use JSON::DWIW;
my $json_obj = JSON::DWIW->new;
my $data = $json_obj->from_json($json_str);
my $str = $json_obj->to_json($da
string) = $json_obj->from_json($json_str);
my $data = JSON::DWIW::deserialize($json_str);
my $error_str = JSON::DWIW::get_error_string();
use JSON::DWIW qw/deserialize_json from_json/
my $data
serialize_json($json_str);
my $error_str = JSON::DWIW::get_error_string();
my $error_string = $json_obj->get_error_string;
my $error_data = $json_obj->get_error_data;
my $stats = $json_obj->get_
t::HTTP::API::Parser::JSON;
BEGIN {
$Net::HTTP::API::Parser::JSON::VERSION = '0.14';
}
# ABSTRACT: Parse JSON
use JSON;
use Moose;
extends 'Net::HTTP::API::Parser';
has _json_parser => (
is
=> 'rw',
isa => 'JSON',
lazy => 1,
default => sub { JSON->new->allow_nonref },
);
sub encode {
my ($self, $content) = @_;
$self->_json_parser->encode($content);
}
sub
e {
my ($self, $content) = @_;
$self->_json_parser->decode($content);
}
1;
__END__
=pod
=head1 NAME
Net::HTTP::API::Parser::JSON - Parse JSON
=head1 VERSION
version 0.14
=head1 SYNOPSI
package JSON::RPC::Common::Marshal::Catalyst;
use Moose;
use Carp qw(croak);
extends qw(JSON::RPC::Common::Marshal::HTTP);
#OVERRIDE TO CATALYST REQUEST
sub post_request_to_call {
my ( $self, $req
equest body
my $body = $request->body;
my $content = do { local $/; <$body> };
$self->json_to_call( $content );
}
sub write_result_to_response {
my ( $self, $result, $response, @a
->$key(delete $args{$key});
}
}
#Copied from base class
#JSON::RPC::Common::Marshal::HTTP introduced a "die" here. The
# following keys where left over
package Apache::Voodoo::View::JSON;
$VERSION = "3.0200";
use strict;
use warnings;
use JSON::DWIW;
use base("Apache::Voodoo::View");
sub init {
my $self = shift;
my $config = shift;
$self->
content_type('application/javascript');
$self->{json} = JSON::DWIW->new({
'bad_char_policy' => 'convert',
'pretty' => ($config->{dynamic_loading})?1:0
});
}
sub params {
my $self = shift;
i
or'} = 1;
$self->{data} = $d;
}
sub output {
my $self = shift;
return scalar($self->{json}->to_json($self->{data}));
}
sub finish {
my $self = shift;
$self->{data} = {};
}
sub _stack_trac