2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-09 20:57:11 +00:00

fhem.pl: better number/string parsing in json2nameValue (Forum #125340)

git-svn-id: https://svn.fhem.de/fhem/trunk@25544 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-01-22 15:42:45 +00:00
parent 03d809969a
commit 2a19d496d1

View File

@ -5352,7 +5352,7 @@ json2nameValue($;$$$$)
my %r2;
my $in2 = $val;
while($in2 =~ m/^\s*"([^"]+)"\s*:\s*(.*)$/s) {
while($in2 =~ m/^\s*"([^"]*)"\s*:\s*(.*)$/s) { # 125340
my ($name,$val) = ($1,$2);
$name =~ s/[^a-z0-9._\-\/]/_/gsi;
($err,$in2) = eObj(\%r2, $name, $val, $in2, $prefix);
@ -5378,9 +5378,10 @@ json2nameValue($;$$$$)
$idx++;
}
} elsif($val =~ m/^([0-9.-]+)(.*)$/s) {
} elsif($val =~ m/^((-?[0-9.]+)([eE][+-]?[0-9]+)?)(.*)$/ && # 125340
looks_like_number($1)) {
setVal($ret, $prefix, $name, $1);
$in = $2;
$in = $4;
} elsif($val =~ m/^(true|false)(.*)$/s) {
setVal($ret, $prefix, $name, $1);