I'm trying to get data from the following JSON file using PHP. I specifically want the @name
and additional parameters in the below hierarchy, parsed and put in a tabular format which can be easily read as html.
Considering we may be many types and sub-types wanted to understand the way it could be achieved in php, interactively.
It's probably really simple, but I have no idea how to do this. I'm stuck on what to do after
file_get_contents("output.json")
{
"{http://pmd.sourceforge.net/report/2.0.0}pmd": {
"@{http://www.w3.org/2001/XMLSchema-instance}schemaLocation": "http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd",
"@version": "6.4.0",
"@timestamp": "2018-06-19T07:50:03.152",
"{http://pmd.sourceforge.net/report/2.0.0}file": [{
"@name": "/opt/folder/file.cls",
"{http://pmd.sourceforge.net/report/2.0.0}violation": [{
"@rule": "AvoidGlobalModifier",
"@priority": "3",
"@externalInfoUrl": "https://rule.html",
"@endcolumn": "2",
"@ruleset": "Best Practices",
"@begincolumn": "30",
"@beginline": "21",
"@endline": "313",
"#tail": "\n",
"#text": "\nAvoid using global modifier\n"
}, {
"@rule": "StdCyclomaticComplexity",
"@priority": "3",
"@externalInfoUrl": "https://rule.html",
"@endcolumn": "2",
"@ruleset": "Design",
"@begincolumn": "30",
"@beginline": "21",
"@endline": "313",
"#tail": "\n",
"#text": "\nThe class 'Class' has a Standard Cyclomatic Complexity of 5 (Highest = 18).\n"
}, {
"@rule": "ExcessiveParameterList",
"@priority": "3",
"@externalInfoUrl": "https://rule.html",
"@endcolumn": "6",
"@ruleset": "Design",
"@begincolumn": "29",
"@beginline": "219",
"@endline": "242",
"#tail": "\n",
"#text": "\nAvoid long parameter lists\n"
}, {
"@rule": "Violation",
"@priority": "3",
"@externalInfoUrl": "https://rule.html",
"@endcolumn": "14",
"@ruleset": "Security",
"@begincolumn": "16",
"@beginline": "252",
"@endline": "264",
"#tail": "\n",
"#text": "\nValidate CRUD permission before SOQL/DML operation\n"
}],
"#tail": "\n",
"#text": "\n"
}, {
"@name": "/opt/folder/file2.cls",
"{http://pmd.sourceforge.net/report/2.0.0}violation": {
"@rule": "CRUDViolation",
"@priority": "3",
"@externalInfoUrl": "https://rule.html",
"@endcolumn": "148",
"@ruleset": "Security",
"@begincolumn": "73",
"@beginline": "15",
"@endline": "15",
"#tail": "\n",
"#text": "\nValidate CRUD permission before SOQL/DML operation\n"
},
"#tail": "\n",
"#text": "\n"
}],
"#text": "\n"
}
}