diff --git a/scripts/ZoneMinder/lib/ZoneMinder/General.pm b/scripts/ZoneMinder/lib/ZoneMinder/General.pm index b14b08aae..90e7399ce 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/General.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/General.pm @@ -28,6 +28,7 @@ our %EXPORT_TAGS = ( makePath jsonEncode jsonDecode + jsonLoad systemStatus packageControl daemonControl @@ -536,6 +537,23 @@ sub jsonDecode { return $result; } +sub jsonLoad { + my $file = shift; + my $json = undef; + eval { + require File::Slurp; + my $contents = File::Slurp::read_file($file); + if (!$contents) { + Error("No contents for $file"); + return $json; + } + require JSON; + $json = JSON::decode_json($contents); + }; + Error($@) if $@; + return $json; +} + sub parseNameEqualsValueToHash { my %settings; foreach my $line ( split ( /\r?\n/, $_[0] ) ) {