无法从PHP中的JSON访问“@attributes”:“obj-> @attribute”

时间:2012-11-09 17:45:34

标签: php json syntax-error

  

可能重复:
  PHP/JSON - stdClass Object

我有这个JSON响应:

{
    "findItemsIneBayStoresResponse": {
        "ack": "Success",
        "version": "1.12.0",
        "timestamp": "2012-11-09T17:14:20.543Z",
        "searchResult": {
            "@attributes": {
                "count": "1"
            },
            "item": {
                "itemId": "160884918999",
                "topRatedListing": "false"
            }
        },
        "paginationOutput": {
            "totalPages": "1",
            "totalEntries": "1",
            "pageNumber": "1",
            "entriesPerPage": "100"
        }
    }
}

我试图用PHP访问'@attributes'中的'count'。我认为if ($decoded->findItemsIneBayStoresResponse->searchResult->@attributes->count > 1) {会起作用,但我收到错误:

Parse error: syntax error, unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in /home/ancienta/public_html/category.php on line 40

我该怎么办?

0 个答案:

没有答案