package Sah::Schema::json_or_str;
use strict;
use warnings;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-11-15'; # DATE
our $DIST = 'Sah-Schemas-JSON'; # DIST
our $VERSION = '0.0
07'; # VERSION
our $schema = [any => {
summary => 'A JSON-encoded data or string',
'prefilters' => ['Str::try_decode_json'],
description => <<'_',
You can use this schema if you want to
ine
script as command-line argument or option, it will be tried to be JSON-decoded
first. If the string does not contain valid JSON, it will be left as-is as
string.
This schema is convenient on the
ckage Sah::Schema::hash_from_json;
use strict;
use warnings;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-11-15'; # DATE
our $DIST = 'Sah-Schemas-JSON'; # DIST
our $VERSION = '0.
007'; # VERSION
our $schema = [hash => {
summary => 'Hash, coerced from JSON string',
'prefilters' => ['JSON::decode_str'],
description => <<'_',
You can use this schema if you want to a
a JSON-encoded object
(hash). Data will not be valid if the string does not contain valid JSON.
Note that hash data is accepted, unlike the `json_str::hash` schema which only
accepts hash in JSON-en
ah::Filter::perl::JSON::decode;
use 5.010001;
use strict;
use warnings;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-11-15'; # DATE
our $DIST = 'Sah-Schemas-JSON'; # DIST
our $VE
1,
summary => 'Decode from JSON',
might_fail => 1,
examples => [
{value=>'', valid=>0, summary=>'Empty string is not valid JSON'},
{value=>'null', filt
summary=>'Invalid JSON, missing closing quote'},
{value=>{}, valid=>0, summary=>'Will become something like "HASH(0x560142d4e5e8)" and fail because it is not valid JSON'},
#{v
package Sah::Schema::json_str;
use strict;
use warnings;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-11-15'; # DATE
our $DIST = 'Sah-Schemas-JSON'; # DIST
our $VERSION = '0.007'
t contains valid JSON',
'prefilters' => ['JSON::check_decode'],
description => <<'_',
This schema can be used if you want to accept a string that contains valid JSON.
The JSON string will not
. a JSON-encoded array will not beome an
array) but you know that the string contains a valid JSON. Data will not be
valid if the string does not contain valid JSON.
See also related schema: `json_or
## no critic: TestingAndDebugging::RequireStrict
package Sah::SchemaR::hash_from_json;
our $DATE = '2022-11-15'; # DATE
our $VERSION = '0.007'; # VERSION
our $rschema = do{my$var={base=>"hash",clset
JSON-encoded object\n(hash). Data will not be valid if the string does not contain valid JSON.\n\nNote that hash data is accepted, unlike the `json_str::hash` schema which only\naccepts hash in JSON-
amples=>[{summary=>"Empty string is not a valid JSON",valid=>0,value=>""},{summary=>"Valid JSON but not a hash",valid=>0,value=>1},{summary=>"Valid JSON but not a hash",valid=>0,value=>"[]"},{summary=
e
# bundled with this file.
#
=head1 NAME
FP::JSON
=head1 SYNOPSIS
use FP::JSON qw(to_json);
my $settings = {
output_format => "JSON", # or "Mint"
auto_numbers => 1,
},
# pretty => 1, # extra re-parsing step at the end
};
use FP::List;
is to_json([10, list(20,30), {40=> "foo", bar=> 50}], $settings),
'[
10,
[
20,
30
" : 50
}
]
';
=head1 DESCRIPTION
Currently just provides `to_json` to turn some kinds of data into a
JSON or Mint language string. This module will need some work for more
serious use
package WebService::DS::SOP::Auth::V1_1::Request::PUT_JSON;
use strict;
use warnings;
use Carp ();
use JSON::XS qw(encode_json);
use HTTP::Request::Common qw(PUT);
use WebService::DS::SOP::Auth::V1_1:
nt = encode_json($params);
my $sig = create_signature($content, $app_secret);
my $req = PUT $uri, Content => $content;
$req->headers->header('content-type' => 'application/json');
$re
ice::DS::SOP::Auth::V1_1::Request::PUT_JSON
=head1 DESCRIPTION
To create a valid L<HTTP::Request> object for C<PUT> request with content type C<application/json>.
=head1 FUNCTIONS
=head2 $class->c
package WebService::DS::SOP::Auth::V1_1::Request::POST_JSON;
use strict;
use warnings;
use Carp ();
use JSON::XS qw(encode_json);
use HTTP::Request::Common qw(POST);
use WebService::DS::SOP::Auth::V1_
t = encode_json($params);
my $sig = create_signature($content, $app_secret);
my $req = POST $uri, Content => $content;
$req->headers->header('content-type' => 'application/json');
$re
rvice::DS::SOP::Auth::V1_1::Request::POST_JSON
=head1 DESCRIPTION
To create a valid L<HTTP::Request> object for given C<POST> request parameters to send JSON data.
=head1 METHODS
=head2 $class->cr
use strict;
use warnings;
package JSON::Typist::DataPrinter 0.008;
# ABSTRACT: a helper for Data::Printer-ing JSON::Typist data
use Data::Printer use_prototypes => 0;
use Term::ANSIColor qw(colored)
= 'ansi214';
use Sub::Exporter -setup => [ qw( jdump ) ];
#pod =head1 SYNOPSIS
#pod
#pod use JSON::Typist::DataPrinter qw( jdump );
#pod
#pod my $data = get_typed_data_from_your_code();
#pod
#p
},
'JSON::PP::Boolean' => sub { colored([$BOOL_COLOR], $_[0] ? 'true' : 'false') },
}
],
)
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
JSON::Typist::Data
ckage JSON::Typist 0.008;
# ABSTRACT: replace mushy strings and numbers with rigidly typed replacements
#pod =head1 OVERVIEW
#pod
#pod JSON is super useful and everybody loves it. Woo! Go JSON! Go
need to know. You might using JSON for interchange with a
#pod system that needs its types in its values. JSON::Typist is meant for this
#pod problem.
#pod
#pod L<JSON> (in its many variant forms) a
t as the variables are
#pod used. (That's just a weird-o Perl problem.) JSON::Typist is meant to take the
#pod result of JSON-decoding I<immediately> before you use it for anything else. It
#pod re
package Mojolicious::Plugin::Notifications::JSON;
use Mojo::Base 'Mojolicious::Plugin::Notifications::Engine';
# TODO:
# Probably introduce a notify_json function
has key => 'notifications';
# No
my ($self, $c, $notify_array, $rule, $json, %param) = @_;
my $key = $param{key} // $self->key;
return $json unless @$notify_array;
if (!$json || ref $json) {
my @msgs;
foreach (@$noti
-1]]);
};
};
if (!$json) {
return { $key => \@msgs }
}
# Obect is an array
elsif (index(ref $json, 'ARRAY') >= 0) {
push(@$json, { $key => \@msgs });
}
kage File::Dir::Dumper::Stream::JSON::Writer;
$File::Dir::Dumper::Stream::JSON::Writer::VERSION = '0.6.6';
use 5.014;
use strict;
use warnings;
use parent 'Format::JSON::Stream::Writer';
1; # E
:JSON::Writer - writer for a stream of JSON data.
=head1 VERSION
version 0.6.6
=head1 SYNOPSIS
use File::Dir::Dumper::Stream::JSON::Writer ();
my $writer = File::Dir::Dumper::Stream::JSON
kage File::Dir::Dumper::Stream::JSON::Reader;
$File::Dir::Dumper::Stream::JSON::Reader::VERSION = '0.6.6';
use 5.014;
use strict;
use warnings;
use parent 'Format::JSON::Stream::Reader';
1; # E
JSON::Reader - reader for stream of JSON objects.
=head1 VERSION
version 0.6.6
=head1 SYNOPSIS
use File::Dir::Dumper::Stream::JSON::Reader ();
my $reader = File::Dir::Dumper::Stream::JSON
ry_decode_json;
use 5.010001;
use strict;
use warnings;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-08-25'; # DATE
our $DIST = 'Data-Sah-Filter-perl-Str-try_decode_json'; # DIST
our $VERSION = '0.003'; # VERSION
sub meta {
+{
v => 1,
summary => 'JSON-decode if we can, otherwise leave string as-is',
examples => [
{value=>undef, summary
};
my $res = {};
$res->{modules}{"JSON::PP"} //= 0;
$res->{expr_filter} = join(
"",
"do { my \$decoded; eval { \$decoded = JSON::PP->new->allow_nonref->decode($dt); 1 };
package Amon2::Plugin::Web::JSON;
use strict;
use warnings;
use JSON 2 qw/encode_json/;
use Amon2::Util ();
my $_JSON = JSON->new()->ascii(1);
my %_ESCAPE = (
'+' => '\\u002b', # do not eval as
) = @_;
unless ($c->can('render_json')) {
Amon2::Util::add_method($c, 'render_json', sub {
my ($c, $stuff) = @_;
# for IE7 JSON venularity.
# see http:
//www.atmarkit.co.jp/fcoding/articles/webapp/05/webapp05a.html
my $output = $_JSON->canonical( $conf->{canonical} ? 1 : 0 )->encode($stuff);
$output =~ s!([+<>])!$_ESCAPE{$1}!g
ckage JSON::XS::ByteString;
use 5.008;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(encode_json encode_json_pretty encode_json_unblessed encode_json_unbl
essed_pretty decode_json decode_json_safe);
our $VERSION = 1.007000;
require XSLoader;
XSLoader::load('JSON::XS::ByteString', $VERSION);
=head1 NAME
JSON::XS::ByteString - A more predictable and co
entation for JSON
=head1 SYNOPSIS
use JSON::XS::ByteString qw(encode_json encode_json_unblessed decode_json decode_json_safe);
$json_string = encode_json($perl_data);
$json_string_prett
package cPanel::APIClient::Utils::JSON;
# Copyright 2020 cPanel, L. L. C.
# All rights reserved.
# http://cpanel.net
#
# This is free software; you can redistribute it and/or modify it under the
# sa
erl itself. See L<perlartistic>.
use strict;
use warnings;
use JSON ();
my $json;
sub _json {
return $json ||= JSON->new()->utf8(0);
}
sub decode {
return _json()->decode( $_[0] );
}
1;
package Format::JSON::Stream::Reader;
$Format::JSON::Stream::Reader::VERSION = '0.0.1';
use strict;
use warnings;
use 5.014;
sub new
{
my $class = shift;
my $self = bless {}, $class;
$s
elf->_init(@_);
return $self;
}
use Carp ();
use JSON::MaybeXS qw(decode_json);
use Class::XSAccessor accessors => { _in => 'in' };
sub _init
{
my $self = shift;
my $args = shift;
my $self = shift;
if ( $self->_readline() ne "# JSON Stream by Shlomif - Version 0.2.0\n" )
{
Carp::confess "No header for JSON stream";
}
return;
}
sub fetch
{
my $se
package Format::JSON::Stream::Writer;
$Format::JSON::Stream::Writer::VERSION = '0.0.1';
use strict;
use warnings;
use 5.014;
sub new
{
my $class = shift;
my $self = bless {}, $class;
$s
elf->_init(@_);
return $self;
}
use Carp ();
use JSON::MaybeXS ();
use Class::XSAccessor accessors => { _out => '_out' };
sub _init
{
my $self = shift;
my $args = shift;
$self->_
= shift;
$self->_print("# JSON Stream by Shlomif - Version 0.2.0");
return;
}
sub put
{
my $self = shift;
my $token = shift;
$self->_print( JSON::MaybeXS->new( canonical => 1
Format::JSON::Stream;
$Format::JSON::Stream::VERSION = '0.0.1';
use 5.014;
use strict;
use warnings;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Format::JSON::Stream - a stream of JSON data.
=
t-JSON-Stream>
=item *
RT: CPAN's Bug Tracker
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Format-JSON-
rmat-JSON-Stream>
=item *
CPAN Testers
The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
L<http://www.cpantesters.org/distro/F/Format-JSON-Stre