Skip to content

Commit 6c76619

Browse files
committed
Emulate XML::Simple SuppressEmpty option
1 parent e43f35b commit 6c76619

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/Paws/Net/XMLResponse.pm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package Paws::Net::XMLResponse;
99
default => sub {
1010
return XML::Hash::XS->new(
1111
force_array => qr/^(?:item|Errors)/i,
12+
# SuppressEmpty => undef,
1213
);
1314
}
1415
);
@@ -26,6 +27,7 @@ package Paws::Net::XMLResponse;
2627
}
2728

2829
my $struct = eval { $self->_xml_parser->xml2hash($response->content) };
30+
$struct = _emulate_xml_simple_supress_empty($struct);
2931
if ($@){
3032
return Paws::Exception->throw(
3133
message => $@,
@@ -37,6 +39,20 @@ package Paws::Net::XMLResponse;
3739
return $struct;
3840
}
3941

42+
sub _emulate_xml_simple_supress_empty {
43+
my ($struct) = @_;
44+
return undef unless $struct;
45+
foreach (keys %$struct) {
46+
if (ref $struct->{$_} eq 'HASH') {
47+
_emulate_xml_simple_supress_empty($struct->{$_})
48+
}
49+
elsif (defined $struct->{$_} && $struct->{$_} eq '') {
50+
$struct->{$_} = undef;
51+
}
52+
}
53+
return $struct;
54+
}
55+
4056
sub process {
4157
my ($self, $call_object, $response) = @_;
4258

0 commit comments

Comments
 (0)