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:
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|