package JSON;
use strict;
package Java::Json { import => "javax.json.Json" }
package Java::JsonParser { import => "javax.json.stream.JsonParser" }
package Java::JsonParser::Event { import => "j
m.JsonParser.Event" }
package String {};
package StringReader { import => "java.io.StringReader" }
sub parse {
my $str = shift;
my $result;
my Java::JsonParser $parser = Java::Json-
arser->hasNext()) {
my Java::JsonParser::Event $event = $parser->next();
my $ev = $event;
say "event $ev";
#if ($event == Java::JsonParser::START_ARRAY) {
#
package Perlito5::JSON;
sub ast_dumper {
my $seen = {};
my $level = '';
my $pos = '[TODO - recursive structure is not supported]';
return _dumper( $_[0], $level, $seen, $pos );
}
package JSON::PP::Boolean;
use strict;
use overload (
"0+" => sub { ${$_[0]} },
"++" => sub { $_[0] = ${$_[0]} + 1 },
"--" => sub { $_[0] = ${$_[0]} - 1 },
fallback => 1,
);
$JSON::PP::Boolean::VERSION = '2.97001';
1;
__END__
=head1 NAME
JSON::PP::Boolean - dummy module providing JSON::PP::Boolean
=head1 SYNOPSIS
# do not "use" yourself
=head1 DESCRIPTION
Thi
verload resolution for Storable and similar modules. See
L<JSON::PP> for more info about this class.
=head1 AUTHOR
This idea is from L<JSON::XS::Boolean> written by Marc Lehmann <schmorp[at]schmorp.
age JSON;
use Perlito5::JSON;
# use strict;
sub import {
my $pkg = shift;
my $callpkg = caller(0);
*{ $callpkg . "::encode_json" } = \&encode_json;
*{ $callpkg . "::decode_json" }
= \&decode_json;
return;
}
sub encode_json {
Perlito5::JSON::ast_dumper($_[0]);
}
sub _string_loop {
my $s = "";
while (1) {
if ($_[0] =~ /\G"[ \t\r\n]*/gc) {
#
$_[0] =~ /\G([0-9a-fA-F]{4})/gc
or die "unexpected end of string while parsing JSON string, at character offset " . pos($_[0]);
my $uni = hex($1);
if
package JSON::MaybeXS;
use strict;
use warnings FATAL => 'all';
use base qw(Exporter);
our $VERSION = '1.003009';
$VERSION = eval $VERSION;
sub _choose_json_module {
return 'Cpanel::JSON::XS' i
l/JSON/XS.pm'};
return 'JSON::XS' if $INC{'JSON/XS.pm'};
my @err;
return 'Cpanel::JSON::XS' if eval { require Cpanel::JSON::XS; 1; };
push @err, "Error loading Cpanel::JSON::
return 'JSON::XS' if eval { require JSON::XS; 1; };
push @err, "Error loading JSON::XS: $@";
return 'JSON::PP' if eval { require JSON::PP; 1 };
push @err, "Error loading JSON::PP: $@";
ization::json;
use JSON ();
use constant {
serialization => 'json',
websocket_data_type => 'text',
};
#The following have trouble dealing with anything that isn’t UTF-8;
#but JSON must al
UTF-32 anyway as per RFC 7159.
#So, any application that wants to send binary data via JSON needs to use
#Base64, hex, or some such.
*stringify = *JSON::encode_json;
*parse = *JSON::decode_json;
1;
View::Default::Json;
use strict;
use warnings;
require UR;
our $VERSION = "0.47"; # UR $VERSION;
class UR::Object::Set::View::Default::Json {
is => 'UR::Object::View::Default::Json',
has_con
eViews::Json;
use strict;
use warnings;
require UR;
our $VERSION = "0.47"; # UR $VERSION;
use UR::Object::Type::View::AvailableViews::Xml;
class UR::Object::Type::View::AvailableViews::Json {
is => 'UR::Object::View::Default::Json',
has_constant => [
perspective => { value => 'available-views' },
],
};
sub _jsobj {
my $self = shift;
my $subject = $self->subject;
package UR::Value::JSON;
use strict;
use warnings;
use JSON;
class UR::Value::JSON {
is => 'UR::Value',
};
my $_JS_CODEC = new JSON->allow_nonref;
sub __serialize_id__ {
shift;
return
ackage UR::Object::View::Default::Json;
use strict;
use warnings;
require UR;
our $VERSION = "0.47"; # UR $VERSION;
use JSON;
class UR::Object::View::Default::Json {
is => 'UR::Object::View::De
lue => 'json' },
],
has_optional => [
encode_options => { is => 'ARRAY', default_value => ['ascii', 'pretty', 'allow_nonref', 'canonical'], doc => 'Options to enable on the JSON object
; see the documentation for the JSON Perl module' },
],
};
my $json;
sub _json {
my ($self) = @_;
return $json if defined $json;
$json = JSON->new;
foreach my $opt ( @{ $self->en
ue::View::Default::Json;
use strict;
use warnings;
use UR;
# These Values inherit from Text which inherits from UR::Object::View::Default::Text
class UR::Value::View::Default::Json {
is => 'UR::V
package CGI::OptimalQuery::JSON;
use strict;
use warnings;
no warnings qw( uninitialized );
use base 'CGI::OptimalQuery::Base';
use CGI();
use JSON::XS();
sub output {
my $o = shift;
my $title =
er}->($$o{httpHeader}->(-type => 'application/json', -attachment => "$title.json").'[');
my @selCols = @{ $o->get_usersel_cols() };
my $encoder = JSON::XS->new->utf8();
while(my $rec = $o->fetch
s::ApiExtensionsApiServer::Pkg::Apis::Apiextensions::V1beta1::JSON;
use Moose;
use IO::K8s;
has 'Raw' => (is => 'ro', isa => 'Str' );
sub to_json { IO::K8s->new->object_to_json(shift) }
1;
quest::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
use parent 'HTTP::Message::JSON', 'HTTP::Request';
our $VERSION = $LWP::JSON::Tiny::VERSION;
use Encode ();
use LWP::JSON::Tiny;
SON::MaybeXS ();
=head1 NAME
HTTP::Request::JSON - a subclass of HTTP::Request that understands JSON
=head1 SYNOPSIS
my $request = HTTP::Request::JSON->new(PATCH => "$base_url/death_ray");
# $re
t's OK to send JSON back
$request->json_content(
{
self_destruct_mechanism => 'disabled',
users_allowed_to_override => [],
}
);
# Request content is JSON-encoded, and
package LWP::JSON::Tiny;
use strict;
use warnings;
no warnings 'uninitialized';
use HTTP::Request::JSON;
use HTTP::Response::JSON;
use JSON::MaybeXS;
use LWP;
use LWP::UserAgent::JSON;
# Have you u
E
LWP::JSON::Tiny - use JSON natively with LWP objects
=head1 VERSION
This is version 0.014.
=head1 SYNOPSIS
my $user_agent = LWP::UserAgent::JSON->new;
my $request = HTTP::Request::JSON->new(P
x/upload_dance");
$request->json_content({ contents => [qw(badger mushroom snake)] });
my $response = $user_agent->request($request);
if (my $upload_id = $response->json_content->{upload}{id}) {
P::Response::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
use LWP::JSON::Tiny;
use parent 'HTTP::Message::JSON', 'HTTP::Response';
use Encode;
our $VERSION = $LWP::JSON::Tiny::VERS
TP::Response::JSON - a subclass of HTTP::Response that understands JSON
=head1 SYNOPSIS
if ($response->isa('HTTP::Response::JSON')) {
Your::Own::Code::do_something($response->json_content);
}
ple subclass of HTTP::Response that implements a method
L</json_content> which returns the JSON-decoded contents of the response.
=head2 json_content
Out: $perl_data
Returns the Perl data structur
TP::Message::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
our $VERSION = $LWP::JSON::Tiny::VERSION;
=head1 NAME
HTTP::Message::JSON - a very simple superclass for JSON HTTP message
s
=head1 DESCRIPTION
This is a very simple superclass used by HTTP::Request::JSON and
HTTP::Response::JSON. It overrides the default behaviour of the HTTP::Headers
method content_is_text.
=head2 co
nt type application/json.
Otherwise uses the default behaviour of HTTP::Headers.
=cut
sub content_is_text {
my ($self) = @_;
if ($self->content_type eq 'application/json') {
return
rAgent::JSON;
use strict;
use warnings;
no warnings 'uninitialized';
use HTTP::Request::JSON;
use LWP::JSON::Tiny;
use Scalar::Util ();
use parent 'LWP::UserAgent';
our $VERSION = $LWP::JSON::Tiny:
AME
LWP::UserAgent::JSON - a subclass of LWP::UserAgent that understands JSON
=head1 SYNOPSIS
my $user_agent = LWP::UserAgent::JSON->new;
my $request = HTTP::Request::JSON->new(...);
my $resp
P::Response::JSON') if we got back JSON
=head1 DESCRIPTION
This is a subclass of LWP::UserAgent which recognises if it gets
JSON output back, and if so returns an L<HTTP::Response::JSON> object inst
package Catalyst::View::Base::JSON;
use base 'Catalyst::View';
use HTTP::Status;
use Scalar::Util;
our $VERSION = 0.003;
our $CLASS_INFO = 'Catalyst::View::Base::JSON::_ClassInfo';
my $inject_http
_headers($_->headers)
if $self->can('amend_headers');
unless($_->has_body) {
my $json = $self->render($possible_override_data);
if(my $param = $self->$class_info->callback_param
allback parameter $cb";
$json = "$cb($json)";
}
$_->body($json);
}
}
}
sub render {
my ($self, $possible_override_data) = @_;
my $to_json_encode = $possible_override_dat
st::View::Base::JSON::_ClassInfo;
use Moo;
use Scalar::Util;
use Catalyst::Utils;
our $DEFAULT_JSON_CLASS = 'JSON::MaybeXS';
our $DEFAULT_CONTENT_TYPE = 'application/json';
our %JSON_INIT_ARGS = (
);
has json => (
is=>'ro',
required=>1,
init_arg=>undef,
lazy=>1,
default=>sub {
my $self = shift;
eval "use ${\$self->json_class}; 1" ||
die "Can't use ${\$self->json_class},
$@";
return $self->json_class->new(
$self->json_init_args);
});
has content_type => (
is=>'ro',
required=>1,
default=>$DEFAULT_CONTENT_TYPE);
has returns_status => (
is=>'ro',