2017-09-28 6 views
-1

Bigcommerce API의 표시 데이터 :PHP : 내가합니다 (Bigcommerce :: getCategories를 실행할 때이 같은 데이터의 배열을 받고) PHP를 통해 Bigcommerce의 데이터를 표시하기 위해 노력하고

[0] => Bigcommerce\Api\Resources\Category Object 
     (
      [ignoreOnCreate:protected] => Array 
       (
        [0] => id 
        [1] => parent_category_list 
       ) 

      [ignoreOnUpdate:protected] => Array 
       (
        [0] => id 
        [1] => parent_category_list 
       ) 

      [fields:protected] => stdClass Object 
       (
        [id] => 88 
        [parent_id] => 0 
        [name] => Dell 
        [description] => 
        [sort_order] => 0 
        [page_title] => 
        [meta_keywords] => 
        [meta_description] => 
        [layout_file] => 
        [parent_category_list] => Array 
         (
          [0] => 88 
         ) 

        [image_file] => 
        [is_visible] => 1 
        [search_keywords] => 
        [url] => /dell/ 
       ) 

      [id:protected] => 88 
      [ignoreIfZero:protected] => Array 
       (
       ) 

      [fieldMap:protected] => Array 
       (
       ) 

     ) 

을하지만 때 내가 이 문을 사용하여 표시 할 수 있도록이 JQuery 전달할보십시오 : <?php echo json_encode($categories); ?> 빈 개체 배열을 얻고있다, Bigcommerce API 개체 배열을 얻는 데 올바른 방법은 무엇입니까? 감사. 코드의 첫 번째 줄에서

답변

0

:

[0] => Bigcommerce\Api\Resources\Category Object

당신은 객체가 아닌 배열을 가지고있다. 먼저 배열로 전송 해보세요.

$array = (array) $yourObject; 
+2

네, 생각하면됩니다. json_encode는 객체를 완전히 인코딩 할 수 있습니다 (json_encode가 객체를 인코딩 할 수 없다고 생각되는 것처럼 보입니다). 객체의'protected' 속성을 인코딩하지는 않을 것입니다. 배열에 캐스트하면 PHP의 배열에는 가시성 개념이 없으므로'protected' 속성을 완전히 제거합니다. – hanshenrik