package Data::Ref::JSON;
use strict;
use Carp;
use warnings;
use diagnostics;
use Data::Dumper;
use Try::Tiny;
# 0 is 'disabled'
my $debugLevel=0;
BEGIN {
use Exporter ();
use vars qw($VERS
ess it
This can be used as an object or a procedure
=cut
=head2 As Procedure
use Data::Ref::JSON qw(walk);
my %tc = (
'HL01-01' => {
'HL02-01' => [
'element 0',
=> 'this is key 6'
}
}
);
walk(\%tc);
=cut
=head2 As Object
use Data::Ref::JSON;
my %tc = (
'HL01-01' => {
'HL02-01' => [
'element 0',
!/usr/bin/env perl
# using object interface
# read JSON, create Perl Data Structure and print references
=head1 drp.pl
This script reads in JSON from a file.
The script then prints the values an
f::JSON;
eval { require JSON::Parse };
if ($@) {
die "The JSON::Parse Module must be installed\n";
} else {
JSON::Parse->import( qw(parse_json) );
}
my $debugLevel=0;
# test case file
my $jsonFil
e = 'test-files/adobe-example-5.json';
my $help=0;
GetOptions (
"l|debug-level=i" => \$debugLevel,
"f|test-file=s" => \$jsonFile,
"h|help!" => \$help
) or die usage(1);
if ($help) {
usage();
ex
l not work when passed JSON data
=cut
use strict;
use warnings;
use Data::Dumper;
use IO::File;
use Getopt::Long;
#use lib './lib'; # development use only
use Data::Ref::JSON;
my $debugLevel=0;
#
= $slurpSave;
# read a perl script, and getting the JSON from it
# the hash is $tc in the script
my $tc;
eval $tcStr;
my $dr = Data::Ref::JSON->new (
{
DEBUG => $debugLevel,
DATA => $tc
}
);
passed JSON data, using the Procedural interface.
=cut
use strict;
use warnings;
use Data::Dumper;
use IO::File;
use Getopt::Long;
#use lib './lib'; # development use only
use Data::Ref::JSON qw(wal
> \$tcFile,
"h|help!" => \$help
) or die usage(1);
if ($help) {
usage();
exit;
}
Data::Ref::JSON::setDebugLevel($debugLevel);
my $fh = new IO::File;
$fh->open($tcFile,'r') || die "cannot open
h>;
$/ = $slurpSave;
# read a perl script, and getting the JSON from it
# the hash is $tc in the script
my $tc;
eval $tcStr;
Data::Ref::JSON::pdebug(1,'Test Data tc: ' , Dumper($tc));
walk($tc);
su