Skip to content

Instantly share code, notes, and snippets.

@gonter
Created April 20, 2016 14:53
Show Gist options
  • Save gonter/ae84f2a799caf77ad553056f4912edd3 to your computer and use it in GitHub Desktop.
Save gonter/ae84f2a799caf77ad553056f4912edd3 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use JSON;
my @out=();
FILE: foreach my $file (@ARGV)
{
my $json;
eval { $json= read_json_file($file) };
if ($@) { print STDERR "can not read json data from $file\n"; next FILE; }
push (@out, $json);
}
print encode_json(\@out);
exit (0);
sub read_json_file
{
my $fnm= shift;
# BEGIN load JSON data from file content
local $/;
# print "reading config [$fnm]\n";
open( my $fh, '<:utf8', $fnm ) or return undef;
my $json_text = <$fh>;
decode_json( $json_text );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment