jeudi 4 décembre 2014

Not able to parse json node with json_decode() in php


Vote count:

0




here is the json string in the variable which i am trying to parse with json_decode() function. I am trying to retrieve a specific node information with it but its showing me the blank white page. want to try with the file_get_contents() also to get json string from outer file. I have alreay seen the answer on the previous questions but that didn't helped me



<?php
//$json = file_get_contents('jsonfile.json');
$json = '[
{
"selfie": {
"post_author": "2",
"post_date": "2014-12-02 13:00:00",
"post_date_gmt": "2014-12-02 13:00:00",
"post_content": "this is an example content",
"image": "http://ift.tt/1I3AlMM",
"post_title": "TestJSON"
}
}
]';
$result = json_decode ($json);
echo $result->selfie->post_date;
//echo $result->selfie;
?>


asked 2 mins ago


1 Answer



Vote count:

0





echo $result[0]->selfie->post_date;


answered 4 secs ago

rut2

411





Not able to parse json node with json_decode() in php

Aucun commentaire:

Enregistrer un commentaire