繁体   English   中英

获取对哈希的访问-Ruby

[英]Getting access to a hash - Ruby

我正在尝试获取在binding.pry中找到的数据-这是

[#<Stripe::Card:0x3fc1da530e18 id=card_1A4KjTLcGwfBVD0DjTHzDqsO> JSON: {
  "id": "card_1A4KjTLcGwfBVD0DjTHzDqsO",
  "object": "card",
  "address_city": null,
  "address_country": null,
  "address_line1": null,
  "address_line1_check": null,
  "address_line2": null,
  "address_state": null,
  "address_zip": "42424",
  "address_zip_check": "pass",
  "brand": "Visa",
  "country": "US",
  "customer": "cus_AP91mImLV1GIrS",
  "cvc_check": "pass",
  "dynamic_last4": null,
  "exp_month": 4,
  "exp_year": 2024,
  "fingerprint": "U2Lh3jtN9G5jgtxm",
  "funding": "credit",
  "last4": "4242",
  "metadata": {},
  "name": null,
  "tokenization_method": null
}]

我在控制台中输入以下所有数据: context.customer.sources.data

我试过像这样获取objectcontext.customer.sources.data[:object]但这给了我这个错误=> TypeError: no implicit conversion of Symbol into Integer

我如何获得这些数据?

因为它是一个数组。 因此您应该像context.customer.sources.data[0][:object]context.customer.sources.data[0].object

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM