I am trying to decode below JSON file contents with php.
"notification": {/* code related to notification */ },
"HOME_SCREEN":
{
"Phone":
{
"position": 1 ,
"list":
[
{
"position": 1,
"productID": "105"
}
]
},
},
"notify": { /* code related to notify */},
I followed links here & here & tried as below. but its giving blank page....
$string = file_get_contents("test.json");
$json_a = json_decode($string, true);
foreach ($json_a as $Phone => $person_a)
{
echo isset($person_a['position']);
}
Also tried as :
$json_string = file_get_contents("test.json");
$decoded = json_decode($json_string);
$comments = $decoded->data[0]->comments->data;
foreach($comments as $comment){
$position = $comment->position;
echo $comment['position'];
}
and below:
$url = 'http://url.com/test.json';
$content = file_get_contents($url);
$json = json_decode($content, true);
foreach($json as $i){
echo $i['position'];
}
Edit
checked Json file online, its valid json , same json file in better view : https://pastebin.com/mUEpqfaM