I'm trying to parse the following Json file:
{
"Itineraries" : [{
"date1" : "20/Jan/2016",
"date2" : "20/Jan/1996",
"Options" : [
{
"Num_ID" : [398],
"Quotedwhen" : today,
"Price" : 330.00
}
]
}
]
}
I'm using the following PHP code:
$json2 = file_get_contents("data.json");
var_dump(json_decode($json2));
$parsed_json2 = json_decode($json2);
$price = $parsed_json2->{'Itineraries'}->{'Options'}->{'Price'};
And I get the following error (Line 35 is the last line of the PHP code above):
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/php/jsonread.php on line 35
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/php/jsonread.php on line 35
Do you have any idea of how to solve this problem?
$parsed_json2->Itineraries[0]->Options[0]->Price