[英]When retrieving a Stripe invoice from their API, how do I expand an object to retrieve credit card details and other info?
[英]When retrieving an invoice from the Stripe API, how do I narrow down the results to only retrieve data from one attribute within the object?
我可以直接從Stripe API成功提取發票對象,但是如何修改用於API的唯一URL來縮小結果范圍,使其僅返回一個屬性/鍵中的數據?
我正在拉整個對象,但是我只想要一個鍵的數據。 例如,如果對象包含鍵和值: "currency": "usd"
,如何在對象中搜索“ currency”並僅返回值“ usd”(希望不帶引號)?
我有一個唯一發票的URL,看起來像: https://api.stripe.com/v1/invoices/in_xxxxxxxxxxxxxxxxxxxx
: https://api.stripe.com/v1/invoices/in_xxxxxxxxxxxxxxxxxxxx
如何修改此URL以縮小搜索結果范圍,僅提取此特定發票的貨幣值?
Stripe尚未實現過濾(至少查看其文檔),因此無法僅使用URL來過濾JSON。
您需要編寫一些代碼來提取currency
屬性。 鑒於它的根級別屬性根本不難。
var obj = JSON.parse(// get object);
if (obj) {
var currency = obj.currency;
// do whatever with it here
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.