Ниже приводится выход JSONИзвлечение информации из строки JSON из PHP
{
"bugs": [
{
"is_confirmed": true,
"cc": [
],
"deadline": null,
"qa_contact": "",
"last_change_time": "2016-09-12T04:57:53Z",
"creation_time": "2016-09-12T04:57:03Z",
"keywords": [
],
"classification": "Unclassified",
"assigned_to": "[email protected]",
"priority": "Highest",
"is_open": true,
"creator": "[email protected]",
"target_milestone": "---",
"creator_detail": {
"name": "[email protected]",
"id": 1,
"real_name": "Ashish Sureka",
"email": "[email protected]"
},
"is_cc_accessible": true,
"op_sys": "Windows",
"component": "TestComponent",
"status": "CONFIRMED",
"resolution": "",
"platform": "PC",
"depends_on": [
],
"groups": [
],
"summary": "Checking if Bugzilla REST API is working or not",
"cc_detail": [
],
"assigned_to_detail": {
"name": "[email protected]",
"email": "[email protected]",
"id": 1,
"real_name": "Ashish Sureka"
},
"alias": [
],
"whiteboard": "",
"version": "unspecified",
"url": "",
"see_also": [
],
"id": 1,
"dupe_of": null,
"severity": "critical",
"product": "TestProduct",
"blocks": [
],
"is_creator_accessible": true,
"flags": [
]
}
],
"faults": [
]
}
моей программы
// Location of the resource (Bug Report)
$url = "http://localhost:8080/bugzilla/rest/bug/1";
// Instantiate an instance of cURL
$curl = curl_init();
// cURL settings, URL to send request to
curl_setopt($curl, CURLOPT_URL, $url);
// cURL settings, Return the response as a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Execute the cURL request
$result = curl_exec($curl);
// Close the cURL request
curl_close($curl);
//echo "<BR>Product: ". $result->product;
//echo "<BR>Component: ".$result->component;
//echo "<BR>Version: ".$result->version;
//echo "<BR>Summary: ".$result->summary;
//echo "<BR>Priority: ".$result->priority;
//echo "<BR>Operating System".$result->op_sys;
Я попытался с помощью json_encode
и json_decode
функции и попытался извлечь свойства из объекта или получить информацию из массива, но не может получить продукт, компонент, версию, сводку, приоритет и т. д. от $result
Возможный дубликат [? Как извлечь данные из JSON с PHP] (http://stackoverflow.com/questions/ 29308898/how-do-i-extract-data-from-json-with-php) –