2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

Added recursion-protection

git-svn-id: https://svn.fhem.de/fhem/trunk@3271 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-06-10 15:07:43 +00:00
parent 71eb2407ce
commit 17e1d6b17d

View File

@ -74,7 +74,7 @@ sub
PrintHashJson($$) PrintHashJson($$)
{ {
my ($h, $lev) = @_; my ($h, $lev) = @_;
return if($h->{PrintHashJson});
my $hc = keys %{$h}; my $hc = keys %{$h};
my @str; my @str;
@ -88,7 +88,9 @@ PrintHashJson($$)
} else { } else {
$str .= sprintf("%*s\"%s\": {\n", $lev, " ", $c); $str .= sprintf("%*s\"%s\": {\n", $lev, " ", $c);
if(keys(%{$h->{$c}}) != 0) { if(keys(%{$h->{$c}}) != 0) {
$h->{PrintHashJson} = 1;
$str .= PrintHashJson($h->{$c}, $lev+2); $str .= PrintHashJson($h->{$c}, $lev+2);
delete($h->{PrintHashJson});
} else { } else {
$str .= sprintf("%*s\"null\": \"null\"\n", $lev+4, " "); $str .= sprintf("%*s\"null\": \"null\"\n", $lev+4, " ");
} }