mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
Fix "null" argument converting to "{}"
This commit is contained in:
parent
53da187acc
commit
c305a9aa5b
@ -20,8 +20,13 @@ sub validate_string {
|
|||||||
local $@;
|
local $@;
|
||||||
eval {
|
eval {
|
||||||
my $h = decode_json($string);
|
my $h = decode_json($string);
|
||||||
|
|
||||||
|
if (not defined $h) {
|
||||||
|
$string = 'null';
|
||||||
|
} else {
|
||||||
foreach my $k (keys %$h) { $h->{$k} = substr $h->{$k}, 0, $max_length unless $max_length <= 0; }
|
foreach my $k (keys %$h) { $h->{$k} = substr $h->{$k}, 0, $max_length unless $max_length <= 0; }
|
||||||
$string = encode_json($h);
|
$string = encode_json($h);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
Loading…
Reference in New Issue
Block a user