【发布时间】:2026-02-14 20:20:05
【问题描述】:
我有一个通过 REST 使用 Google 自定义搜索的网络应用。到目前为止,一切正常,但是当我超过分配的每日查询配额时,我想给用户一些关于它的信息。我得到这个 JSON 响应,我可以使用 response.error.code 和 response.error.message 访问“代码”和“消息”数据,但我不知道如何访问子集“错误”,特别是“原因” ”。
我知道这是一个 JSON 问题,但我对此没有太多经验。 这是我收到的 JSON 结构(这是我所期望的)
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceeded",
"message": "This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=323544036192 to enable billing.",
"extendedHelp": "https://console.developers.google.com/billing?project=323544036192"
}
],
"code": 403,
"message": "This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=323544036192 to enable billing."
}
}
【问题讨论】: