You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by fo...@apache.org on 2024/06/12 12:57:08 UTC
(avro) branch main updated: Switch Perl library from JSON::XS to JSON::MaybeXS (#2952)
This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/main by this push:
new c1dc83610 Switch Perl library from JSON::XS to JSON::MaybeXS (#2952)
c1dc83610 is described below
commit c1dc8361049d5c3e498ef5a50004b0af5a58a734
Author: José Joaquín Atria <jj...@gmail.com>
AuthorDate: Wed Jun 12 13:57:03 2024 +0100
Switch Perl library from JSON::XS to JSON::MaybeXS (#2952)
The JSON::MaybeXS library serves as a compatibility layer to allow
users to select the JSON backend that matches their stack, rather than
forcing them to install a specific one, while still benefiting from
the performance boost of XS libraries if they are available.
---
BUILD.md | 2 +-
lang/perl/Changes | 3 +++
lang/perl/Makefile.PL | 2 +-
lang/perl/bin/avro-to-json | 4 ++--
lang/perl/lib/Avro/Protocol.pm | 4 ++--
lang/perl/lib/Avro/Schema.pm | 4 ++--
6 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/BUILD.md b/BUILD.md
index b619b5357..f9c601681 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -14,7 +14,7 @@ The following packages must be installed before Avro can be built:
- Ruby: Ruby 2.7 or greater, ruby-dev, gem, bundler, snappy
- Perl: Perl 5.24.1 or greater, gmake, Module::Install,
Module::Install::ReadmeFromPod, Module::Install::Repository,
- Math::BigInt, JSON::XS, Try::Tiny, Regexp::Common, Encode,
+ Math::BigInt, JSON::MaybeXS, Try::Tiny, Regexp::Common, Encode,
IO::String, Object::Tiny, Compress::ZLib, Error::Simple,
Test::More, Test::Exception, Test::Pod
- Rust: rustc and Cargo 1.65.0 or greater
diff --git a/lang/perl/Changes b/lang/perl/Changes
index 5620745b1..2d4e6c3d5 100644
--- a/lang/perl/Changes
+++ b/lang/perl/Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension Avro
+ - Switch from JSON::XS to JSON::MaybeXS to support
+ multiple JSON backends
+
1.00 Fri Jan 17 15:00:00 2014
- Relicense under apache license 2.0
diff --git a/lang/perl/Makefile.PL b/lang/perl/Makefile.PL
index ffac5e9d1..b5b0a33dd 100644
--- a/lang/perl/Makefile.PL
+++ b/lang/perl/Makefile.PL
@@ -35,7 +35,7 @@ requires 'Compress::Zstd';
requires 'Encode';
requires 'Error::Simple';
requires 'IO::String';
-requires 'JSON::XS';
+requires 'JSON::MaybeXS';
requires 'Object::Tiny';
requires 'Regexp::Common';
requires 'Try::Tiny';
diff --git a/lang/perl/bin/avro-to-json b/lang/perl/bin/avro-to-json
index 2ca4efc44..ff6f733b1 100644
--- a/lang/perl/bin/avro-to-json
+++ b/lang/perl/bin/avro-to-json
@@ -23,9 +23,9 @@ use warnings;
use Avro::DataFileReader;
use Carp;
use IO::File;
-use JSON::XS;
+use JSON::MaybeXS ();
-my $j = JSON::XS->new->allow_nonref;
+my $j = JSON::MaybeXS->new->allow_nonref;
my $fh = IO::File->new(shift || croak "specify a file");
my $reader = Avro::DataFileReader->new(
diff --git a/lang/perl/lib/Avro/Protocol.pm b/lang/perl/lib/Avro/Protocol.pm
index ca892bc74..f701f7992 100644
--- a/lang/perl/lib/Avro/Protocol.pm
+++ b/lang/perl/lib/Avro/Protocol.pm
@@ -20,7 +20,7 @@ use strict;
use warnings;
use Carp;
-use JSON::XS();
+use JSON::MaybeXS ();
use Try::Tiny;
use Avro::Protocol::Message;
use Avro::Schema;
@@ -35,7 +35,7 @@ use Object::Tiny qw{
our $VERSION = '++MODULE_VERSION++';
-my $json = JSON::XS->new->allow_nonref;
+my $json = JSON::MaybeXS->new->allow_nonref;
sub parse {
my $class = shift;
diff --git a/lang/perl/lib/Avro/Schema.pm b/lang/perl/lib/Avro/Schema.pm
index 5240caed3..160f85ded 100644
--- a/lang/perl/lib/Avro/Schema.pm
+++ b/lang/perl/lib/Avro/Schema.pm
@@ -20,12 +20,12 @@ use strict;
use warnings;
use Carp;
-use JSON::XS();
+use JSON::MaybeXS ();
use Try::Tiny;
our $VERSION = '++MODULE_VERSION++';
-my $json = JSON::XS->new->allow_nonref;
+my $json = JSON::MaybeXS->new->allow_nonref;
sub parse {
my $schema = shift;