#!/usr/bin/perl
##
## JSON_minify.pm
## Copyright ©2018 Rémi Cohen-Scali
##
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated docu
VERSION = '1.1.1';
package JSON_minify;
use strict;
use warnings;
sub new {
my $class = shift;
return bless {}, $class;
}
##
## minify_string
##
## Minify a json content available in the 2
lf param: the object instance
my $self = shift;
# input_string param: a string containing json
my $input_string = shift;
# strip_space param: a boolean that specify if caller
# wa
package JSON::Repair;
use parent Exporter;
our @EXPORT_OK = qw/repair_json/;
our %EXPORT_TAGS = (all => \@EXPORT_OK);
use warnings;
use strict;
use utf8;
use Carp;
# This Perl version is required bec
errors from
# JSON::Parse.
use 5.014;
use JSON::Parse '0.58';
use C::Tokenize '$comment_re';
our $VERSION = '0.08';
sub repair_json
{
my ($broken, %options) = @_;
my $jp = JSON::Parse->new
ose};
my $output = $broken;
while (1) {
# Try various repairs. This continues until the JSON is
# valid, or none of the repairs have worked. After a
# successful repair, "next;" should be
package Zing::Encoder::Json;
use 5.014;
use strict;
use warnings;
use registry 'Zing::Types';
use routines;
use Data::Object::Class;
extends 'Zing::Encoder';
use JSON -convert_blessed_universall
# METHODS
method decode(Str $data) {
return JSON->new->allow_nonref->convert_blessed->decode($data);
}
method encode(HashRef $data) {
return JSON->new->allow_nonref->convert_blessed->encode($da
ncoder::Json - JSON Serialization Abstraction
=cut
=head1 ABSTRACT
JSON Data Serialization Abstraction
=cut
=head1 SYNOPSIS
use Zing::Encoder::Json;
my $encoder = Zing::Encoder::Json->new;
r::JSON::DontTouchMyUTF8;
our $AUTHORITY = 'cpan:SCHWIGON';
# ABSTRACT: Pass through known-utf8 data untouched to Elasticsearch.
$BenchmarkAnything::Storage::Search::Elasticsearch::Serializer::JSON::D
ot alone!)
use Moo;
use JSON::MaybeXS 1.002002 ();
has 'JSON' => ( is => 'ro', default => sub { JSON::MaybeXS->new } );
with 'Search::Elasticsearch::Role::Serializer::JSON';
use namespace::clean;
ing::Storage::Search::Elasticsearch::Serializer::JSON::DontTouchMyUTF8 - Pass through known-utf8 data untouched to Elasticsearch.
=head2 JSON
The JSON instance which does not contain special utf-8 f
This module provides some extra datatypes that are used by common
serialisation formats such as JSON or CBOR. The idea is to have a
repository of simple/small constants and containers that can be sh
void extra dependencies in JSON::PP,
# we alias *Types::Serialiser::Boolean with JSON::PP::Boolean.
package JSON::PP::Boolean;
*Types::Serialiser::Boolean:: = *JSON::PP::Boolean::;
}
{
#
C<JSON::PP::Boolean>. When printed, the classname
with usually be C<JSON::PP::Boolean>, but isa tests and stash pointer
comparison will normally work correctly (i.e. Types::Serialiser::true ISA
JSON::
##-*- Mode: CPerl -*-
## File: DDC::Format::JSON.pm
## Author: Bryan Jurish <moocow@cpan.org>
## Description:
## + DDC Query utilities: output formatting: Data::Dumper
##============================
==========================================
package DDC::Format::JSON;
use JSON;
use Carp;
use strict;
##======================================================================
## Globals
our @ISA = q
##-- json prettification level (default:0)
## jxs => $jxs, ##-- underlying JSON object
## )
sub new {
my $that = shift;
my $fmt = bless {
level=>0,
jxs =>JSON->new->u
plate::Plugin::JSON::Moo;
our $AUTHORITY = 'cpan:JWRIGHT';
our $VERSION = '0.04';
=pod
=encoding utf8
=head1 NAME
Alt::Template::Plugin::JSON::Moo - Alternate Template::Plugin::JSON - using Moo
=
ALT_INSTALL=OVERWRITE cpanm Alt::Template::Plugin::JSON::Moo
[% USE JSON %]
=head1 DESCRIPTION
This is a modification of L<Template::Plugin::JSON>, switching it from using L<Moose> to
using L<Moo
> and L<Type::Tiny>. This allows for the use of the JSON Template plugin
without loading Moose or causing the Moosification of all your Moo classes and
roles.
=head1 BUGS
The use of L<namespace::cl
package HTTP::Entity::Parser::JSON;
use strict;
use warnings;
use JSON::MaybeXS qw/decode_json/;
use Encode qw/encode_utf8/;
sub new {
bless [''], $_[0];
}
sub add {
my $self = shift;
i
{
$self->[0] .= $_[0];
}
}
sub finalize {
my $self = shift;
my $p = decode_json($self->[0]);
my @params;
if (ref $p eq 'HASH') {
while (my ($k, $v) = each %$p) {
::JSON - parser for application/json
=head1 SYNOPSIS
use HTTP::Entity::Parser;
my $parser = HTTP::Entity::Parser->new;
$parser->register('application/json','HTTP::Entity::Parser::JSON')
package File::JSON::Slurper;
$File::JSON::Slurper::VERSION = '1.00';
use 5.006;
use strict;
use warnings;
use parent 'Exporter';
use JSON::MaybeXS qw/ encode_json decode_json /;
use File::Slurper qw/
= qw/ read_json write_json /;
sub read_json
{
my $json = read_binary(@_);
return decode_json($json);
}
sub write_json
{
my ($filename, $ref) = @_;
my $json = encode_json($ref);
$json);
}
1;
=head1 NAME
File::JSON::Slurper - slurp a JSON file into a data structure, and the reverse
=head1 SYNOPSIS
use File::JSON::Slurper qw/ read_json write_json /;
my $ref = read_json(
:JSON;
use strict;
use warnings;
use Algorithm::Diff qw(diff);
use Cpanel::JSON::XS qw(encode_json);
use Sub::Exporter -setup => { exports => [ 'json_diff' ] };
our $VERSION = '1.000';
sub json_
}
return encode_json([
map { defined($changes[$_]) ? { element => $_, %{$changes[$_]} } : () }
0 .. $#changes
]);
}
=head1 NAME
Algorithm::Diff::JSON - find the difference
s between two lists and report on them in JSON
=head1 SYNOPSIS
This perl code:
use Algorithm::Diff::JSON qw(json_diff);
my $json = json_diff(
[0, 1, 2, 3, 4, 5, 6],
package JSON::Encode::TableData;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2020-10-22'; # DATE
our $DIST = 'JSON-Encode-TableData'; # DIST
our $VERSION = '0.002'; # VERSION
use str
ict;
use warnings;
use JSON::MaybeXS ();
use Exporter qw(import);
our @EXPORT_OK = qw(encode_json);
sub encode_json {
my $input = shift;
# BEGIN copy-pasted from App::td with some modificat
T;
} else {
goto ENCODE_DIRECTLY;
}
ENCODE_AND_FORMAT: {
my $encoder = JSON::MaybeXS->new(allow_nonref=>1);
require UUID::Random;
my $tag = UUID::Random::ge
lt::JSON;
$Data::Crumbr::Default::JSON::VERSION = '0.1.2';
# ABSTRACT: "JSON" profile for Data::Crumbr::Default
use Data::Crumbr::Util;
sub profile {
my $json_encoder = Data::Crumbr::Util::json_le
ey_encoder => $json_encoder,
value_encoder => $json_encoder,
};
} ## end sub profile
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Data::Crumbr::Default::JSON - "JSON" profile for Da
version 0.1.2
=head1 DESCRIPTION
Profile for JSON encoder
=head1 INTERFACE
=over
=item B<< profile >>
my $profile = Data::Crumbr::Default::JSON->profile();
returns a default profile, i.e. e
package JSON::SchemaValidator::Pointer;
use strict;
use warnings;
use base 'Exporter';
our @EXPORT_OK = qw(pointer);
use URI::Escape qw(uri_unescape);
sub pointer {
my ($json, $pointer) = @_;
ter =~ m/^#/;
$pointer = uri_unescape($pointer);
$pointer =~ s{^#/?}{};
my $top = $json;
foreach my $part (split m{/}, $pointer) {
$part =~ s{\~1}{\/}g;
$part =~ s{\
package JSON::Immutable::XS;
use parent 'Export::XS';
use 5.020;
use strict;
use warnings;
use XS::Framework;
=head1 NAME
JSON::Immutable::XS
=cut
our $VERSION = '0.1.3';
XS::Loader::bootstrap();
=head1 DESCRIPTION
Fast and simple abstract node-tree based storage with JSON support. Usefull for reading JSON configs, keeping it in the memory and don't worrying about mutability. Has XPath-like
t use RapidJSON as JSON parser. L<https://rapidjson.org/>
=cut
=head1 SYNOPSIS
use JSON::Immutable::XS;
# you can provide this variable to XS and use it there
my $dict = JSON::Immutabl
package JSON::SchemaValidator::Result;
use strict;
use warnings;
use JSON;
sub new {
my $class = shift;
my (%params) = @_;
my $self = {};
bless $self, $class;
$self->{errors}
ors {
my $self = shift;
return $self->{errors};
}
sub errors_json {
my $self = shift;
return JSON::encode_json($self->{errors});
}
sub add_error {
my $self = shift;
if (@_
package JSON::SchemaValidator;
use strict;
use warnings;
our $VERSION = '1.04';
use B ();
use Storable ();
require Carp;
use Time::Piece;
use JSON::SchemaValidator::Result;
use JSON::Schema
return $self;
}
sub formats { shift->{formats} }
sub validate {
my $self = shift;
my ($json, $schema) = @_;
$schema = Storable::dclone($schema);
my $context = {
root =>
};
$self->_collect_ids($context, $schema);
my $result = $self->_validate($context, $json, $schema);
return $result;
}
sub _collect_ids {
my $self = shift;
my ($context, $sc
package JSON::Feed::Types {
use Type::Library -base;
use Type::Utils -all;
use Types::Standard qw<Str Int Bool Dict Optional ArrayRef HashRef>;
use Types::Common::Numeric qw< PositiveO
rZeroInt >;
my $AuthorWithoutExt = declare JSONFeedAuthorWithoutExt => as Dict[
name => Optional[Str],
url => Optional[Str],
avatar => Optional[Str],
], where {
exists($_->{name}) || exists($_->{url}) || exists($_->{avatar})
};
my $Author = declare JSONFeedAuthor => as HashRef, where {
my $val = $_;
my %o = map { $_ => $val->{$_} } g
package JSON::Feed;
our $VERSION = '1.001';
use Moo;
use namespace::clean;
use JSON qw<to_json from_json>;
use JSON::Feed::Types qw<JSONFeed JSONFeedItem>;
has feed => (
is => 'ro',
defa
eturn +{
version => "https://jsonfeed.org/version/1",
title => 'Untitle',
items => [],
};
},
isa => JSONFeed,
);
around BUILDARGS => sub {
y ( $orig, $class, %args ) = @_;
return +{
feed => +{
version => "https://jsonfeed.org/version/1",
items => [],
%args
}
};
};
sub get {
package ETL::Yertl::Format::json;
our $VERSION = '0.044';
# ABSTRACT: JSON read/write support for Yertl
#pod =head1 SYNOPSIS
#pod
#pod =head1 DESCRIPTION
#pod
#pod =head1 SEE ALSO
#pod
#pod L<ETL::Ye
return (
[ 'JSON::XS' => 0 ],
[ 'JSON::PP' => 0 ],
);
}
sub _json_writer {
my ( $self ) = @_;
$self->{_json_writer} ||= do {
my $json = $self->{formatter_clas
ter_class} ne 'JSON::XS' ) {
$json->indent_length(3);
}
$json;
};
}
sub read_buffer {
my ( $self, $buffref, $eof ) = @_;
my $json = $self->{_json_reader} ||= $
use utf8;
package JSON::API::v1::Resource;
our $VERSION = '0.002';
use Moose;
use namespace::autoclean;
use Carp qw(croak);
# ABSTRACT: A JSON API Resource object
has id => (
is => 'ro',
is => 'ro',
isa => 'Defined',
predicate => 'has_relationships',
);
sub TO_JSON {
my $self = shift;
if ($self->has_id && $self->has_type) {
return {
qw(
JSON::API::v1::Roles::TO_JSON
JSON::API::v1::Roles::MetaObject
);
__PACKAGE__->meta->make_immutable;
__END__
=pod
=encoding UTF-8
=head1 NAME
JSON::API::v1::Resource - A JSON API Res