mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
69_SoftliqCloud.pm: Fix garbage JSON
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24401 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2c6890dce3
commit
42869c9f1c
@ -21,6 +21,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
# Changelog:
|
||||
# 0.1.07: - 2021-05-08 - Optimize garbage JSON processing
|
||||
# 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
|
||||
@ -55,7 +56,7 @@ use Digest::MD5 qw(md5);
|
||||
|
||||
use FHEM::Core::Authentication::Passwords qw(:ALL);
|
||||
|
||||
my $version = "0.1.06";
|
||||
my $version = "0.1.07";
|
||||
|
||||
my $missingModul = '';
|
||||
eval 'use MIME::Base64::URLSafe;1' or $missingModul .= 'MIME::Base64::URLSafe ';
|
||||
@ -1965,6 +1966,23 @@ sub Ready {
|
||||
return;
|
||||
}
|
||||
|
||||
sub splitTest {
|
||||
my $buf = shift;
|
||||
my $name = "sd18";
|
||||
my @bufs;
|
||||
$buf =~ s///xsm;
|
||||
my $index = index( $buf, '}{' );
|
||||
if ( $index > 0 ) {
|
||||
Log3( $name, LOG_RECEIVE, "[$name] - Splitting double-JSON buffer" );
|
||||
push( @bufs, decode_json(substr( $buf, 0, $index + 1 ) ));
|
||||
push( @bufs, decode_json(substr( $buf, $index + 1 )));
|
||||
}
|
||||
else {
|
||||
push( @bufs, $buf );
|
||||
}
|
||||
return Dumper(@bufs);
|
||||
}
|
||||
|
||||
sub wsReadDevIo {
|
||||
my $hash = shift;
|
||||
my $name = $hash->{NAME};
|
||||
@ -1976,6 +1994,7 @@ sub wsReadDevIo {
|
||||
}
|
||||
$buf =~ s///xsm;
|
||||
$buf =~ s/\\x\{1e\}//xsm;
|
||||
|
||||
#if ( !( $buf =~ /}$/xsm ) ) {
|
||||
# $buf = substr( $buf, 0, rindex( $buf, "}" ) );
|
||||
#}
|
||||
@ -1988,7 +2007,8 @@ sub wsReadDevIo {
|
||||
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)));
|
||||
push( @bufs, substr( $buf, 0, $index + 1 ) );
|
||||
push( @bufs, substr( $buf, $index + 1 ) );
|
||||
}
|
||||
else {
|
||||
push( @bufs, $buf );
|
||||
|
Loading…
x
Reference in New Issue
Block a user