Skip to content

Commit

Permalink
Switch Perl library from JSON::XS to JSON::MaybeXS (#2952)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jjatria authored Jun 12, 2024
1 parent 7e2c89b commit c1dc836
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lang/perl/Changes
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion lang/perl/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lang/perl/bin/avro-to-json
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions lang/perl/lib/Avro/Protocol.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lang/perl/lib/Avro/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c1dc836

Please sign in to comment.