98_JsonList2.pm: fix problem with filter (Forum #45328)
git-svn-id: https://svn.fhem.de/fhem/trunk@13320 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -34,16 +34,13 @@ JsonList2_Escape($)
|
|||||||
sub
|
sub
|
||||||
JsonList2_dumpHash($$$$$$)
|
JsonList2_dumpHash($$$$$$)
|
||||||
{
|
{
|
||||||
my ($arrp, $name, $h, $isReading, $si, $attr) = @_;
|
my ($arrp, $name, $h, $isReading, $showInternal, $attr) = @_;
|
||||||
my $ret = "";
|
my $ret = "";
|
||||||
my %filter;
|
my %filter = map { $_=>1 } @$attr if(@$attr);
|
||||||
@filter{ @$attr } = (undef) x @$attr if @$attr;
|
|
||||||
|
|
||||||
my @arr = grep { $si || $_ !~ m/^\./
|
my @arr = grep { ($showInternal || $_ !~ m/^\./) &&
|
||||||
and $isReading || !ref($h->{$_})
|
($isReading || !ref($h->{$_}) ) &&
|
||||||
and !%filter || exists $filter{$_}
|
(!@$attr || $filter{$_}) } sort keys %{$h};
|
||||||
} sort keys %{$h};
|
|
||||||
|
|
||||||
for(my $i2=0; $i2 < @arr; $i2++) {
|
for(my $i2=0; $i2 < @arr; $i2++) {
|
||||||
my $k = $arr[$i2];
|
my $k = $arr[$i2];
|
||||||
$ret .= " \"".JsonList2_Escape($k)."\": ";
|
$ret .= " \"".JsonList2_Escape($k)."\": ";
|
||||||
@@ -59,7 +56,7 @@ JsonList2_dumpHash($$$$$$)
|
|||||||
if(@arr > 1) {
|
if(@arr > 1) {
|
||||||
push @{$arrp}, " \"$name\": {\n$ret }";
|
push @{$arrp}, " \"$name\": {\n$ret }";
|
||||||
} else {
|
} else {
|
||||||
push @{$arrp}, " \"$name\": { }";
|
push @{$arrp}, " \"$name\": {$ret }";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user