Ensure parameters to "each" is a hash in TO_JSON and from_hash

This commit is contained in:
Ampem Darko
2015-10-21 13:35:48 +00:00
parent 0f75b053c8
commit 57e3ea3e9c

View File

@@ -28,7 +28,7 @@ sub to_hash {
sub TO_JSON {
my $self = shift;
my $_data = {};
foreach my $_key (keys $self->get_attribute_map) {
foreach my $_key (keys %{$self->get_attribute_map}) {
if (defined $self->{$_key}) {
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
}
@@ -40,7 +40,7 @@ sub TO_JSON {
sub from_hash {
my ($self, $hash) = @_;
# loop through attributes and use swagger_types to deserialize the data
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
if ($_type =~ /^array\[/i) { # array
my $_subclass = substr($_type, 6, -1);
my @_array = ();