You don't really need Path::Tiny. If I didn't have it, I would have done something like this using just standard perl:
#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=11165436
use warnings;
use JSON::PP;
sub names
{
my ($data) = @_;
if( 'ARRAY' eq ref $data )
{
map names($_), @$data;
}
elsif( 'HASH' eq ref $data )
{
map { my $id = $_; map "$id.$_", names($data->{$_}) } keys %$data;
}
else { "\n" }
}
@ARGV or @ARGV = 'd.11165436.json'; # FIXME filename
print map s/\.$//r, names decode_json join '', <>;
This would allow you to put the JSON file name on the command line, or if you didn't put any arguments on the command line, would run the program
against a test file.
|