mijares93 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Iterate JSON File
by VinsWorldcom (Prior) on Aug 02, 2018 at 16:52 UTC | |
by mijares93 (Initiate) on Aug 03, 2018 at 14:28 UTC | |
by AnomalousMonk (Archbishop) on Aug 03, 2018 at 15:27 UTC | |
by VinsWorldcom (Prior) on Aug 03, 2018 at 17:03 UTC | |
Re: Iterate JSON File
by kcott (Archbishop) on Aug 06, 2018 at 06:45 UTC |
Back to
Seekers of Perl Wisdom