簡體   English   中英

從Stripe API檢索發票時,如何縮小結果范圍以僅從對象內的一個屬性檢索數據?

[英]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來縮小結果范圍,使其僅返回一個屬性/鍵中的數據?

這是“檢索發票”的Stripe API參考

我正在拉整個對象,但是我只想要一個鍵的數據。 例如,如果對象包含鍵和值: "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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM