sub flattened_json { my ($cur_node, $top_path, $put_here) = @_; $top_path //= []; $put_here //= {}; if (ref $cur_node eq "HASH") { flattened_json($$cur_node{$_}, [ @$top_path, $_ ], $put_here) for sort keys %$cur_node; } elsif (ref $cur_node eq "ARRAY") { flattened_json($$cur_node[$_], [ @$top_path, $_ ], $put_here) for 0 .. @$cur_node - 1; } else { $$put_here{ join " ➔ ", map { $json_do->pretty(0)->encode($_) =~ s/➔/➔➔/gr } @$top_path } = $json_do->pretty(0)->encode($cur_node) =~ s/➔/➔➔/gr; } return $put_here; }