donglun2024 2014-07-03 13:44
浏览 31
已采纳

获取类别JSON中的JSON对象

{
 meta: {}
 notifications: []
 response: {}
}

FULL JSON = https://api.foursquare.com/v2/venues/4c6397fbec94a5937d472cca/tips?sort=recent&oauth_token=QABX2VQDBCHYJOHYQUGMNMBBA3KZY41YOOVNT5MY1OFYFYNA&v=20140703

$asObjects = json_decode($json);

foreach ($asObjects as $obj) 
{
    echo $obj->response->text;
    echo "<br>";
}

This method do not work because text in response : {} how can i get text ?

  • 写回答

1条回答 默认 最新

  • dongqie2028 2014-07-03 14:08
    关注

    After seeing your full json, you need to iterate on the items array and then show the text for each item :

    $jsonObj = json_decode($json);
    
    foreach ($jsonObj->response->tips->items as $obj) 
    {
        echo $obj->text;
        echo "<br>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?