in reply to Iterate JSON File

G'day mijares93,

Welcome to the Monastery.

[Sorry, I'm a little late to the party on this one: I'm catching up after some travelling.]

The data returned from decode_json is typically a complex data structure and you can access its internal parts quite easily. Consider this short script:

#!/usr/bin/env perl use strict; use warnings; use autodie; use JSON; my $json_file = 'pm_1219718_data.json'; my $json_text = do { open my $fh, '<', $json_file; local $/; <$fh> }; my $perl_data = decode_json $json_text; for (@{$perl_data->{observations}[0]{status}}) { print "$_->{path}\n" }

Output:

_L7= _L2= _L1= _L6=-1 _L6=-2

The "$json_file" is what you posted plus

] }

to close the "observations" array (with the ']') and the JSON object as a whole (with the '}').

"... I am new to Perl ..."

Here's some suggested reading:

— Ken