我从cleeng API获得了这个响应;如何将这个响应JSON

问题描述:

Cleeng_Entity_Collection Object 
(
    [entityType:protected] => Cleeng_Entity_SubscriptionOffer 
    [items:protected] => Array 
     (
      [0] => Cleeng_Entity_SubscriptionOffer Object 
       (
        [id:protected] => S955494970_US 
        [publisherEmail:protected] => [email protected] 
        [url:protected] => 
        [title:protected] => Annual subscription 
        [description:protected] => 
        [period:protected] => year 
        [price:protected] => 49.99 
        [applicableTaxRate:protected] => 0 
        [currency:protected] => USD 
        [accessToTags:protected] => Array 
         (
          [0] => d962607d3d4c4e3c98a343c7bcb64027 
         ) 

        [active:protected] => 1 
        [createdAt:protected] => 1473681112 
        [updatedAt:protected] => 1473858745 
        [geoRestrictionEnabled:protected] => 
        [geoRestrictionType:protected] => 
        [geoRestrictionCountries:protected] => Array 
         (
         ) 

        [pending:protected] => 
        [country] => US 
        [socialCommissionRate] => 0 
        [averageRating] => 4 
        [contentType] => 
        [freePeriods] => 0 
        [freeDays] => 0 
        [expiresAt] => 
       ) 
     ) 
    [totalItemCount:protected] => 5 
    [pending:protected] => 
) 

转换所有您需要做的仅仅是集合转换成规则排列,然后json_encode()的结果,像这样:

<?php 

    $entityCollection = "???"; // THIS IS THE DATA FROM Cleeng_Entity_Collection Object 
    $entityArray  = $entityCollection->toArray(); 
    $entityJSON  = json_encode($entityArray); 
+0

我不能够得到保护的数据。我怎样才能得到它 – solomon

+0

我们可以将未受保护的数据更改为json ....但我需要受保护的数据来更改JSON – solomon