From: Robert 'phaylon' Sedlacek Date: Tue, 19 Jun 2012 21:49:12 +0000 (+0000) Subject: arrays as hash value data X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53cf6a708b19ed0117257919aeaad18301107719;p=scpubgit%2FJSON-Tree-Viewer.git arrays as hash value data --- diff --git a/br.pl b/br.pl index 21eec68..8f29ef2 100644 --- a/br.pl +++ b/br.pl @@ -128,6 +128,17 @@ sub mangle_structure { columns => [ 'key', 'value' ], data => [ map +{ key => $_, value => $data->{$_} }, sort keys %$data ], }]; + } elsif (ref($data) eq 'ARRAY') { + if (not grep { not ref($_) eq 'HASH' } @$data) { + my %key; + $key{$_} = 1 + for map { keys %$_ } @$data; + return [{ + columns => [sort keys %key], + show_columns => 1, + data => $data, + }]; + } } elsif (blessed($data) and $data->isa('IO::All::Dir')) { return [{ columns => [ 'name', 'explore' ], @@ -192,6 +203,11 @@ sub render_table { sub render_el { my ($self, $whole, $key, $part) = @_; if (ref($part) eq 'ARRAY') { + if ($key eq 'entries') { + if (grep { ref($_) eq 'HASH' } @$part) { + return $self->link_to($whole->{name}, $key); + } + } return join(', ', @$part); } if (ref($part) eq 'HASH') {