title: Convert Stripe API response to JSON using stripe-php library
body: <p>I'm accessing customer data from the <a href="https://stripe.com/docs/api/php#customer_object" rel="noreferrer">Stripe API</a>, which I'd like to convert to JSON. Usually I'd convert an object to an array and use <code>json_encode()</code> but I don't seem able to in this case, even when trying to access the nested arrays.</p>
  
  <p>This is the response I'm trying to convert to json:</p>
  
  <pre><code>Stripe_Customer Object
  (
      [_apiKey:protected] =&gt; MY_KEY_IS_HERE
      [_values:protected] =&gt; Array
          (
              [id] =&gt; cus_2dVcTSc6ZtHQcv
              [object] =&gt; customer
              [created] =&gt; 1380101320
              [livemode] =&gt; 
              [description] =&gt; Bristol : John Doe
              [email] =&gt; someone6@gmail.com
              [delinquent] =&gt; 
              [metadata] =&gt; Array
                  (
                  )
  
              [subscription] =&gt; 
              [discount] =&gt; 
              [account_balance] =&gt; 0
              [cards] =&gt; Stripe_List Object
                  (
                      [_apiKey:protected] =&gt; MY_KEY_IS_HERE
                      [_values:protected] =&gt; Array
                          (
                              [object] =&gt; list
                              [count] =&gt; 1
                              [url] =&gt; /v1/customers/cus_2dVcTSc6ZtHQcv/cards
                              [data] =&gt; Array
                                  (
                                      [0] =&gt; Stripe_Object Object
                                          (
                                              [_apiKey:protected] =&gt; MY_KEY_IS_HERE
                                              [_values:protected] =&gt; Array
                                                  (
                                                      [id] =&gt; card_2dVcLabLlKkOys
                                                      [object] =&gt; card
                                                      [last4] =&gt; 4242
                                                      [type] =&gt; Visa
                                                      [exp_month] =&gt; 5
                                                      [exp_year] =&gt; 2014
                                                      [fingerprint] =&gt; NzDd6OkHnfElGUif
                                                      [customer] =&gt; cus_2dVcTSc6ZtHQcv
                                                      [country] =&gt; US
                                                      [name] =&gt; John Doe
                                                      [address_line1] =&gt; 
                                                      [address_line2] =&gt; 
                                                      [address_city] =&gt; 
                                                      [address_state] =&gt; 
                                                      [address_zip] =&gt; 
                                                      [address_country] =&gt; 
                                                      [cvc_check] =&gt; pass
                                                      [address_line1_check] =&gt; 
                                                      [address_zip_check] =&gt; 
                                                  )
  
                                              [_unsavedValues:protected] =&gt; Stripe_Util_Set Object
                                                  (
                                                      [_elts:Stripe_Util_Set:private] =&gt; Array
                                                          (
                                                          )
  
                                                  )
  
                                              [_transientValues:protected] =&gt; Stripe_Util_Set Object
                                                  (
                                                      [_elts:Stripe_Util_Set:private] =&gt; Array
                                                          (
                                                          )
  
                                                  )
  
                                              [_retrieveOptions:protected] =&gt; Array
                                                  (
                                                  )
  
                                          )
  
                                  )
  
                          )
  
                      [_unsavedValues:protected] =&gt; Stripe_Util_Set Object
                          (
                              [_elts:Stripe_Util_Set:private] =&gt; Array
                                  (
                                  )
  
                          )
  
                      [_transientValues:protected] =&gt; Stripe_Util_Set Object
                          (
                              [_elts:Stripe_Util_Set:private] =&gt; Array
                                  (
                                  )
  
                          )
  
                      [_retrieveOptions:protected] =&gt; Array
                          (
                          )
  
                  )
  
              [default_card] =&gt; card_2dVcLabLlKkOys
          )
  
      [_unsavedValues:protected] =&gt; Stripe_Util_Set Object
          (
              [_elts:Stripe_Util_Set:private] =&gt; Array
                  (
                  )
  
          )
  
      [_transientValues:protected] =&gt; Stripe_Util_Set Object
          (
              [_elts:Stripe_Util_Set:private] =&gt; Array
                  (
                  )
  
          )
  
      [_retrieveOptions:protected] =&gt; Array
          (
          )
  
  )
  </code></pre>
  
  <p>Any help greatly appreciated!</p>