Convert Stripe API response to JSON using stripe-php library

前端 未结 7 1747
迷失自我
迷失自我 2021-01-01 21:06

I\'m accessing customer data from the Stripe API, which I\'d like to convert to JSON. Usually I\'d convert an object to an array and use json_encode() but I don

7条回答
  •  渐次进展
    2021-01-01 21:45

    If, like me, you arrived here looking for the python 2.7 solution, simply cast the stripe_object to str(). This triggers the object's inner __str__() function which converts the object into a JSON string.

    E.g.

    charge = stripe.Charge....
    print str(charge)
    

提交回复
热议问题