69_SoftliqCloud.pm: Split JSON to avoid multiple root nodes

git-svn-id: https://svn.fhem.de/fhem/trunk@24369 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
KernSani
2021-05-01 22:25:31 +00:00
parent 324a32814e
commit 22b11b6fbf

View File

@@ -21,6 +21,8 @@
#
##############################################################################
# Changelog:
# 0.1.07: - 2021-04-30 - Split JSON strings to avoid processing multiple root nodes, part 2
# - Changed password storage to (new) common package
# 0.1.06: - 2021-04-26 - Split JSON strings to avoid processing multiple root nodes
# 0.1.05: Fixed setting numeric parameters
# 0.1.04: ANother fix to avoid "garbage" in JSON
@@ -91,6 +93,7 @@ use constant {
};
my $EMPTY = q{};
my $SPACE = q{ };
my $COMMA = q{,};
## Import der FHEM Funktionen
BEGIN {
@@ -1983,7 +1986,15 @@ sub wsReadDevIo {
}
Log3( $name, LOG_DEBUG, qq([$name] Received from DevIo: $buf) );
my @bufs = split (/}\{/xsm, $buf);
my @bufs;
my $index = index($buf, '}{');
if ($index > 0) {
Log3 ($name, LOG_RECEIVE, "[$name] - Splitting double-JSON buffer");
@bufs = split(/,/xsm,join($COMMA,substr($buf,0,$index),Substr($buf,$index+1)));
}
else {
push(@bufs,$buf);
}
foreach my $bufi (@bufs) {
Log3 ($name, LOG_RECEIVE, "[$name] - Extracted".$bufi );