From 45a2c074f6d4bd528e6003c2f5b38b072ff6427c Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Mon, 6 Sep 2021 08:54:29 +0200 Subject: [PATCH 1/4] [messages-perl] Output JSON object fields in alphabetical order Found by running the Gherkin test suite while refactoring it to use Cucumber::Messages. --- messages/perl/lib/Cucumber/Messages/Message.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/perl/lib/Cucumber/Messages/Message.pm b/messages/perl/lib/Cucumber/Messages/Message.pm index 2f26f5df3c2..df5302da425 100644 --- a/messages/perl/lib/Cucumber/Messages/Message.pm +++ b/messages/perl/lib/Cucumber/Messages/Message.pm @@ -45,7 +45,7 @@ use Moo; my $json = JSON::MaybeXS->new( - utf8 => 0, pretty => 0, indent => 0 + utf8 => 0, pretty => 0, indent => 0, canonical => 1 ); sub _camelize { From fef979b5154289c9bd270668de5a6cb58f937161 Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Mon, 6 Sep 2021 08:55:51 +0200 Subject: [PATCH 2/4] [messages-perl] Do not include undefined (null) field values in output Found by running the Gherkin tests. --- messages/perl/lib/Cucumber/Messages/Message.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/perl/lib/Cucumber/Messages/Message.pm b/messages/perl/lib/Cucumber/Messages/Message.pm index df5302da425..d783c871ff6 100644 --- a/messages/perl/lib/Cucumber/Messages/Message.pm +++ b/messages/perl/lib/Cucumber/Messages/Message.pm @@ -80,7 +80,7 @@ sub _to_hash { map { __PACKAGE__->_camelize($_) => _to_hash( $value->{$_}, %args, type => $types->{$_} ) - } keys %$value + } grep { defined $value->{$_} } keys %$value }; } else { From e8202139f1821724d325115746537d700bb21641 Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Mon, 6 Sep 2021 08:57:36 +0200 Subject: [PATCH 3/4] [messages-perl] Remove stray debugging library inclusion --- messages/perl/lib/Cucumber/Messages/Message.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/messages/perl/lib/Cucumber/Messages/Message.pm b/messages/perl/lib/Cucumber/Messages/Message.pm index d783c871ff6..3e4df1ab58b 100644 --- a/messages/perl/lib/Cucumber/Messages/Message.pm +++ b/messages/perl/lib/Cucumber/Messages/Message.pm @@ -106,7 +106,6 @@ sub _from_hash { my $type = $args{type} =~ s/^\[\]//r; return [ map { _from_hash( $_, %args, type => $type ) } @$value ]; } - use Data::Dumper; croak 'No type supplied to deserialize hash' unless $args{type}; From b849d41bcd4a22453fbbec5fbb9816565bfba14e Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Mon, 6 Sep 2021 12:48:57 +0200 Subject: [PATCH 4/4] [messages] Update CHANGELOG.md --- messages/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index 0129dd253ae..8979d668d8e 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +* Perl: incorrectly included `null` values & guaranteed field order + ([#1727](https://github.com/cucumber/common/pull/1727) [ehuelsmann]) + ## [17.1.0] - 2021-09-01 ### Added