MooseX::Types::JSON;
use strict;
use warnings;
use 5.008003;
# ABSTRACT: JSON datatype for Moose
our $VERSION = '1.01'; # VERSION
use MooseX::Types -declare => [qw/ JSON relaxedJSON /];
use Moose:
use JSON (); ## no critic (Community::PreferredAlternatives)
subtype JSON,
as "Str",
where { ref( eval { 'JSON'->new->decode($_) } ) ne '' },
message { "Must be valid JSON" };
coerce JSON,
via { 'JSON'->new->allow_nonref->encode($_) };
subtype relaxedJSON,
as "Str",
where { ref( eval { 'JSON'->new->relaxed->decode($_) } ) ne '' },
message { "Must be at least relaxed JSON" };
co
I/O: CDB: tied read-only access via CDB_File, JSON values
package Lingua::TT::CDBFile::JSON;
use Lingua::TT::CDBFile;
use Lingua::TT::Dict::JSON;
use JSON::XS;
use Carp;
use IO::File;
use strict;
##
=====================
## Globals & Constants
our @ISA = qw(Lingua::TT::CDBFile Lingua::TT::Dict::JSON);
##==============================================================================
## Constructo
## + %opts, %$doc:
## ##-- new options
## jxs => $jxs, ##-- underlying JSON::XS object; see jsonxs() method
## ##
## ##-- user options, inherited from TT::CDBFile
## file =>
ingua::TT::Dict::JSON.pm
## Author: Bryan Jurish <TT/IO.pm>
## Descript: TT Utils: dictionary: JSON
package Lingua::TT::Dict::JSON;
use Lingua::TT::Dict;
use Lingua::TT::IO;
use JSON::XS;
use Carp;
u
# + %opts, %$dict:
## dict => \%key2val, ##-- dict data; values are refs (encoded/decoded via JSON)
sub new {
my $that = shift;
return $that->SUPER::new(@_);
}
##=============================
ods: Access and Manipulation
## $jxs = $obj->jsonxs()
sub jsonxs {
return $_[0]{jxs} if (ref($_[0]) && defined($_[0]{jxs}));
return $_[0]{jxs} = JSON::XS->new->utf8(0)->allow_nonref;
}
##=======
idApp::JSON::MixedEncoder;
use strict;
use warnings;
use Scalar::Util 'blessed';
use Data::Dumper;
use base 'JSON::PP';
our @EXPORT = qw{
encode_json decode_json encode_json_utf8 decode_json_utf8
encode_json_ascii decode_json_ascii
};
# ---
# These are values that we might encounter as ScalarRefs and how to
# translate them into safe values for the JSON encoder. There are
# only a few cases
fied this is where they should be put.
# (Note: \0 and \1 are already handled and expected by the JSON encoder)
# (Note: vals are lc before being tested, so \'NULL' is already seen as \'null')
our %SC
package RapidApp::View::JSON;
use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::View'; }
use RapidApp::JSON::MixedEncoder;
use Scalar::Util 'blessed', 'reftype';
use HTML::Entities;
us
e RapidApp::Util qw(:all);
=head1 NAME
RapidApp::View::JSON
=head1 DESCRIPTION
This view displays content as a JSON packet that will be used by RapidApp's
client-side javascript.
It also handles
*
so that the browser doesn't screw it up, and then the rendered text of the
HTML should be valid JSON that the Javascript uses.
This is also where error/exceptions are processed. This view used to h
:JSON::ScriptWithData;
use strict;
use warnings;
use Scalar::Util;
use RapidApp::JSON::MixedEncoder 'encode_json';
=head1 NAME
RapidApp::JSON::ScriptWithData
=head1 SYNOPSIS
use RapidApp::JSON:
:ScriptWithData;
use RapidApp::JSON::MixedEncoder 'encode_json';
$swd= RapidApp::JSON::ScriptWithData->new(
'function () {',
'blah(12345);',
'var b= foo(bar(', $self->getSomethi
return encode_json($swd);
=cut
sub new {
my ($class, @args)= @_;
return bless \@args, $class;
}
sub TO_JSON_RAW {
my $self= shift;
return join '', (map { ref $_? encode_json($_) : $_ } @$sel
kage RapidApp::JSON::RawJavascript;
use strict;
use warnings;
use Moose;
use overload '""' => sub { (shift)->stringify(@_) };
sub stringify {
my $self = shift;
return $self->TO_JSON_RAW;
}
has '
js' => ( is => 'rw', isa => 'Str' );
# compat with RapidApp::JSONFunc API:
sub func { (shift)->js }
around BUILDARGS => sub {
my $orig= shift;
my $class= shift;
if (scalar(@_) == 1 && !ref $_[0])
js => $_[0] ); # interpret single-param as a javascript fragment
} else {
return $class->$orig(@_);
}
};
sub TO_JSON_RAW {
return (shift)->js;
}
no Moose;
__PACKAGE__->meta->make_immutable;
1;
age CHI::Serializer::JSON;
$CHI::Serializer::JSON::VERSION = '0.61';
use CHI::Util qw(json_encode json_decode);
use Moo;
use strict;
use warnings;
sub serialize {
return json_encode( $_[1] );
}
sub deserialize {
return json_decode( $_[1] );
}
1;
package JSON::DJARE::Writer;
$JSON::DJARE::Writer::VERSION = '0.02';
use strict;
use warnings;
use Moo;
use JSON qw();
use Carp qw/croak/;
our @CARP_NOT;
=head1 NAME
JSON::DJARE::Writer
=head1 VERS
rsion 0.02
=head1 DESCRIPTION
Simple writer of DJARE documents
=head1 SYNOPSIS
my $writer = JSON::DJARE::Writer->new(
djare_version => '0.0.2', # required
meta_version => '0.1.1',
ional fields
);
### JSON
# There's a _json version of both producer methods that returns a JSON string
my $json = $writer->data_json(
my $json = $writer->error_json(
# But if you want t
DB::JSON
=head1 DESCRIPTION
Search IMDB for a specific title, process the result and extract the JSON script within. Process the JSON script and return a hash reference.
=cut
package IMDB::JSON;
JSON::VERSION = "0.05";
use strict;
use HTML::TokeParser;
use LWP::Simple qw($ua get);
use IO::Socket::SSL;
use JSON::XS;
=head1 SYNOPSIS
use IMDB::JSON;
use Data::Dumper;
my $IMDB = IMDB::JSON
IMDB::JSON object, options can be passed to the object by specifying them
=head3 OPTIONS
=over
=item base_url
The base URL to start from. This is usually https://www.imdb.com
=item raw_json
If t
ngs;
package JSON::Schema::Draft201909; # git description: v0.129-5-g0e1dd16
# vim: set ts=8 sts=2 sw=2 tw=100 et :
# ABSTRACT: (DEPRECATED) Validate data against a schema
# KEYWORDS: JSON Schema data
06, feature => 'bareword_filehandles';
use strictures 2;
use Moo;
use namespace::clean;
extends 'JSON::Schema::Modern';
around BUILDARGS => sub {
my ($orig, $class, @args) = @_;
return $class->
8
=head1 NAME
JSON::Schema::Draft201909 - (DEPRECATED) Validate data against a schema
=head1 VERSION
version 0.130
=head1 DESCRIPTION
This module is deprecated in favour of L<JSON::Schema::Moder
::JSON;
use Moo::Role;
use LWP::JSON::Tiny;
# Have you updated the version number in the POD below?
our $VERSION = '1.000';
$VERSION = eval $VERSION;
=head1 NAME
Test::Mock::LWP::Distilled::JSON -
ackage My::JSON::Test::LWP::UserAgent;
use Moo;
extends 'LWP::UserAgent::JSON';
with 'Test::Mock::LWP::Distilled', 'Test::Mock::LWP::Distilled::JSON';
sub filename_suffix { 'my-json-test' }
WP::Distilled> that
handles the very common case of APIs that return JSON. I<If> you are happy
that only the HTTP code and the JSON content of any website response are
important (you don't need to rem
package Log::Log4perl::Layout::JSON::Readable;
use strict;
use warnings;
use parent 'Log::Log4perl::Layout::JSON';
our $VERSION = '1.0.3'; # VERSION
# ABSTRACT: JSON layout, but some fields always co
shift;
my $json = $self->SUPER::render(@_);
if (my $first_fields = $self->first_fields) {
for my $key (reverse @{$first_fields}) {
_move_field_first(\$json, $key);
return $json;
}
sub _move_field_first {
my ($json_ref, $key) = @_;
# a JSON value starts with double quotes, and ends with a
# non-backslash-escaped double quotes
${$json_ref} =~ s
package Log::Any::Adapter::JSON;
our $VERSION = '1.16';
use strict;
use warnings;
use feature 'say';
use Carp qw/ croak confess /;
use Cpanel::JSON::XS;
use Path::Tiny;
use Time::Moment;
use strict
ush ( @{ $log_entry{additional_messages} }, $item);
}
}
my $serializer = Cpanel::JSON::XS->new
->utf8(0)
->pr
::Adapter::JSON - One-line JSON logging of arbitrary structured data
=head1 SYNOPSIS
Get a logger and specify the output destination:
use Log::Any '$log';
use Log::Any::Adapter ('JSON', '/path/
package oCLI::View::JSON;
sub render {
my ( $self, $c ) = @_;
print $c->stash->{json};
}
1;
package JSON::Decode::Regexp;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2021-08-01'; # DATE
our $DIST = 'JSON-Decode-Regexp'; # DIST
our $VERSION = '0.102'; # VERSION
use 5.014004;
s;
#use Data::Dumper;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(from_json);
sub _fail { die __PACKAGE__.": $_[0] at offset ".pos()."\n" }
my %escape_codes = (
"\\" =
$escape_codes{$4} ? $escape_codes{$4} :
$1]eg;
$str;
}
our $FROM_JSON = qr{
(?:
(?&VALUE) (?{ $_ = $^R->[1] })
|
\z (?{ _fail "Unexpected end of input" })
|
package JSON::Create;
use warnings;
use strict;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw/create_json create_json_strict write_json/;
our %EXPORT_TAGS = (
all => \@EXPORT_OK,
e JSONCreatePP controls whether this runs as
# XS or purely Perl.
$noxs = $ENV{JSONCreatePP};
# Did the XS load OK?
our $xsok;
if (! $noxs) {
eval {
require XSLoader;
XSLoader::load ('JSON::
sok = 1;
};
if ($@) {
$xsok = 0;
}
}
if (! $xsok || $noxs) {
require JSON::Create::PP;
JSON::Create::PP->import (':all');
}
sub set_fformat
{
my ($obj, $fformat) = @_;
i
package JSON::Create::Bool;
use warnings;
use strict;
our @ISA = qw!Exporter!;
our @EXPORT = qw!true false!;
our $VERSION = '0.35';
my $t = 1;
my $f = 0;
my $true = bless \$t, __PACKAGE__;
my $fal
ing UTF-8
=head1 NAME
JSON::Create::Bool - Booleans for JSON::Create
=head1 SYNOPSIS
use JSON::Create::Bool;
my %thing = (yes => true, no => false);
print json_create (\%thing);
=hea
This module provides substitute booleans for JSON::Create. These
booleans are intended only to be used for generating C<true> and
C<false> literals in JSON output. They don't work very well for other
=head1 NAME
JSON::Create::PP - Pure-Perl version of JSON::Create
=head1 DESCRIPTION
This is a backup module for JSON::Create. JSON::Create is written
using Perl XS, but JSON::Create::PP offers the
to work exactly like
the XS version.
=cut
package JSON::Create::PP;
use parent Exporter;
our @EXPORT_OK = qw/create_json create_json_strict json_escape/;
our %EXPORT_TAGS = (all => \@EXPORT_OK);
us
Unicode::UTF8 qw/decode_utf8 valid_utf8 encode_utf8/;
use B;
our $VERSION = '0.35';
sub create_json
{
my ($input, %options) = @_;
my $jc = bless {
output => '',
};
$jc->{_strict} =
package File::Serialize::Serializer::JSON5;
our $AUTHORITY = 'cpan:YANICK';
#ABSTRACT: JSON5 serializer for File::Serialize
$File::Serialize::Serializer::JSON5::VERSION = '1.5.1';
use strict;
use warn
ializer::JSON::MaybeXS';
sub extensions { qw/ json5 / };
sub required_modules {
qw/ JSON5 JSON::MaybeXS /
}
sub deserialize {
my( $self, $data, $options ) = @_;
use_module('JSON5');
return JSON5::decode_json5($data,$options);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
File::Serialize::Serializer::JSON5 - JSON5 serializer for File::Serialize
=head1 VERSION
version 1.5.