我正在从测试发票中从Stripe API中提取数据。我正在尝试缩小使用点表示法提取特定键值对的方法,但是由于从嵌套值看似比其余数据更嵌套,我无法从特定键值中提取数据(不确定是否正确)术语)。
这些数据我想拉数据从从period: end:
从period: start:
从线44-46粗略。
如果我在代码中使用点表示法,则当键值对位于同一行时,它可以工作,例如sheet.getRange(3,2).setValue([content.amount_due]);
。但是似乎“ period:end”和“ period:start”嵌套得更深了。
我尝试做类似的事情,[content.lines.data.period.end]
但没有成功。它返回此错误:TypeError: Cannot read property "end" from undefined.
以下是从API中提取的完整数据(注意:"xxxxxxxxxxxxxxxx"
代表已隐藏的数据):
""id"": ""in_xxxxxxxxxxxxxxxx"",
""object"": ""invoice"",
""amount_due"": 800,
""amount_paid"": 800,
""amount_remaining"": 0,
""application_fee"": null,
""attempt_count"": 1,
""attempted"": true,
""auto_advance"": false,
""billing"": ""charge_automatically"",
""billing_reason"": ""subscription_cycle"",
""charge"": ""ch_xxxxxxxxxxxxxxxx"",
""closed"": true,
""created"": 1552077120,
""currency"": ""usd"",
""custom_fields"": null,
""customer"": ""cus_xxxxxxxxxxxxxxxx"",
""date"": 1552077120,
""default_payment_method"": null,
""default_source"": null,
""description"": null,
""discount"": null,
""due_date"": null,
""ending_balance"": 0,
""finalized_at"": 1552080770,
""footer"": null,
""forgiven"": false,
""hosted_invoice_url"": ""https://pay.stripe.com/invoice/invst_xxxxxxxxxxxxxxxx"",
""invoice_pdf"": ""https://pay.stripe.com/invoice/invst_xxxxxxxxxxxxxxxx/pdf"",
""lines"": {
""object"": ""list"",
""data"": [
{
""id"": ""sub_xxxxxxxxxxxxxxxx"",
""object"": ""line_item"",
""amount"": 800,
""currency"": ""usd"",
""description"": null,
""discountable"": true,
""livemode"": false,
""metadata"": {
},
""period"": {
""end"": 1554755515,
""start"": 1552077115
},
SMILET
相关分类