-3
我正在爲我的應用程序集成Stripe付款。它工作正常 - 條紋與JSON響應。從json Python返回字段?
我需要將這些字段中的一些存儲在我的數據庫中。如何檢索特定字段,如客戶,國家和default_card?
{
"account_balance": 0,
"cards": {
"count": 1,
"data": [
{
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"country": "US",
"customer": "cus_2kZQDsySSBFBb3",
"cvc_check": null,
"exp_month": 5,
"exp_year": 2015,
"fingerprint": "Nf1jHB21DkK6brg6",
"id": "card_102kZQ2wq4yXwSPaT66QP0ho",
"last4": "4242",
"name": null,
"object": "card",
"type": "Visa"
}
],
"object": "list",
"url": "/v1/customers/cus_2kZQDsySSBFBb3/cards"
},
"created": 1381729976,
"default_card": "card_102kZQ2wq4yXwSPaT66QP0ho",
"delinquent": false,
"description": "[email protected]",
"discount": null,
"email": null,
"id": "cus_2kZQDsySSBFBb3",
"livemode": false,
"metadata": {},
"object": "customer",
"subscription": null
}
這顯然是一個嵌套的字典結構...所以使用字典API ... BASIC PYTHON –
更準確地說,使用'import json; d = json.loads(s)',其中's'是字符串。 –