Hello Monks, I am new to Perl and i want to parse a JSON File, but right now i am stuck.
Right now i am able to extract data from "observations"->"op_path" which results in: "Lib::Execution", but i want to access to the "status" and extract "kind", "path", "info"
The way i am extracting the data from "observations"->"op_path" is like this
my $decoded = decode_json($json);
my $aref = $decoded->{"observations"};
foreach my $element (@$aref){
$final .= $element->{"op_path"}.",";
}
print $final;
The json file is the following one:
{
"generation_date": "",
"static_info": "",
"justification_files": [],
"test_procedure_files": [
""
],
"observations": [
{
"op_path": "Lib::Execution",
"c_op_name": "Lib",
"mono_info": "",
"status": [
{
"kind": "I",
"path": "_L7=",
"info": "%(MinorFrameCnt)%",
"stat": "O"
},
{
"kind": "I",
"path": "_L2=",
"info": "%(Offset)%",
"stat": "O"
},
{
"kind": "I",
"path": "_L1=",
"info": "%(Period)%",
"stat": "O"
},
{
"kind": "I",
"path": "_L6=-1",
"info": "%(_L3)% = _L8",
"stat": "O"
},
{
"kind": "I",
"path": "_L6=-2",
"info": "_L3 = %(_L8)%",
"stat": "O"
}
]
}
Hope that you guys could help me with this issue
-
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.