From 001857154d0121205270c38335894d5096e5bd72 Mon Sep 17 00:00:00 2001
From: Gerhard Gonter <ggonter@gmail.com>
Date: Mon, 28 Jan 2019 15:42:10 +0100
Subject: [PATCH] use File::Slurper

---
 modules/util/Util/JSON.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/modules/util/Util/JSON.pm b/modules/util/Util/JSON.pm
index 055e45d..bc42cc8 100755
--- a/modules/util/Util/JSON.pm
+++ b/modules/util/Util/JSON.pm
@@ -3,6 +3,7 @@ package Util::JSON;
 
 use strict;
 
+use File::Slurper qw(read_text write_text);
 use JSON -convert_blessed_universally;
 
 sub read_json_file
@@ -12,10 +13,19 @@ sub read_json_file
   # BEGIN load JSON data from file content
   local $/;
   # print "reading config [$fnm]\n";
+
+=begin comment
+
   open( my $fh, '<:utf8', $fnm ) or return undef;
   my $json_text   = <$fh>;
   close ($fh);
   # decode_json( $json_text ); # for some reason, decode_json() barfs when otherwise cleanly read wide characters are present
+
+=end comment
+=cut
+
+  my $json_text= read_text($fnm);
+
   from_json($json_text);
 }
 
@@ -30,10 +40,18 @@ sub write_json_file
   my $json= new JSON;
   my $json_str= $json->allow_blessed->convert_blessed->encode($x);
 
+=begin comment
+
   open (J, '>:utf8', $json_fnm) or die ("can not write to [$json_fnm]");
   syswrite (J, $json_str);
   close (J);
 
+
+=end comment
+=cut
+
+  write_text($fnm, $json_str);
+
   1;
 }
 
@@ -52,6 +70,12 @@ sub get_config_item
 
 __END__
 
+=head1 DEPENDENCIES
+
+=head2 Ubuntu
+
+sudo apt-get install libfile-slurper-perl
+
 =head1 AUTHOR
 
 Gerhard Gonter <ggonter@cpan.org>
-- 
GitLab