JSON 映射
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用 Search Ads 360 Reporting API 的 REST 接口时,您将使用 Search Ads 360 Reporting API 的 .proto 描述符文件中定义的相同资源和类型的 JSON 表示形式。JSON 编码方案遵循协议缓冲区语言指南的 JSON 映射部分中所述的规范编码方案。
一般来说,与服务之间往来的所有顶级消息都是单个 JSON 对象。search
响应是 JSON 对象,其中包含一个 results
数组,该数组包含查询的结果集。
标识符从 snake_case(在协议缓冲区中)转换为 JSON 中的 lowerCamelCase。不过,在使用 search
或 searchStream
发送 Search Ads 360 查询语言查询时,此规则有一个明显的例外情况。无论您使用哪个接口,查询语言本身都使用蛇形命名法。不过,REST 中的查询结果会以普通 JSON 对象的形式返回,并且其标识符采用小驼峰式命名法。
例如,用于提取账号中有效关键字列表的查询在查询本身中使用蛇形命名法 (ad_group_criterion
,而非 adGroupCriterion
):
POST /v0/customers/CUSTOMER_ID/searchAds360:searchStream HTTP/1.1
Host: searchads360.googleapis.com
Content-Type: application/json
Authorization: Bearer ACCESS_TOKEN
{
"query": "SELECT ad_group_criterion.keyword.text
FROM ad_group_criterion
WHERE ad_group_criterion.type = 'KEYWORD'
AND ad_group_criterion.status = 'ENABLED'"
}
不过,响应是对象的 JSON 表示形式(由于此请求使用 searchStream
,因此封装在 JSON 数组中),并使用驼峰式标识符 adGroupCriterion
:
[
{
"results": [
{
"adGroupCriterion": {
"resourceName": "customers/1842689525/adGroupCriteria/55771861891~10003060",
"keyword": {
"text": "pay per click"
}
}
},
...
]
}
]
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eThe Search Ads 360 Reporting API's REST interface uses JSON to represent the resources and types defined in its .proto descriptor files, adhering to the canonical JSON encoding scheme.\u003c/p\u003e\n"],["\u003cp\u003eTop-level messages in REST are single JSON objects, and search responses contain a \u003ccode\u003eresults\u003c/code\u003e array holding the query's result set.\u003c/p\u003e\n"],["\u003cp\u003eIdentifiers are generally transformed from snake_case in protocol buffers to lowerCamelCase in JSON, except within Search Ads 360 Query Language queries which retain snake_case.\u003c/p\u003e\n"],["\u003cp\u003eAlthough Search Ads 360 Query Language uses snake_case, the results returned via REST are standard JSON objects with lowerCamelCase identifiers.\u003c/p\u003e\n"]]],["The Search Ads 360 Reporting API's REST interface uses JSON, mirroring the structure of its .proto descriptor files. Data is exchanged as JSON objects, with `search` responses containing a `results` array. Identifiers convert from *snake_case* in protocol buffers to *lowerCamelCase* in JSON, except within the Search Ads 360 Query Language, which remains *snake_case*. Query results, however, are returned in *lowerCamelCase* format. For instance, a query uses `ad_group_criterion` while the response will be `adGroupCriterion`.\n"],null,["# JSON Mappings\n\nWhen using the Search Ads 360 Reporting API's REST interface, you're working with JSON\nrepresentations of the same resources and types defined in the Search Ads 360 Reporting API's\n[.proto descriptor](https://github.com/googleapis/googleapis/tree/13301267d983903e0eb8e3713cf6d3127ea0ca47/google/ads/searchads360/v0/) files. The JSON encoding scheme follows the\ncanonical encoding scheme described in the\n[JSON Mapping](/protocol-buffers/docs/proto3#json) section of the protocol\nbuffers *Language Guide*.\n\nIn general, all top-level messages to and from\n[services](https://github.com/googleapis/googleapis/tree/13301267d983903e0eb8e3713cf6d3127ea0ca47/google/ads/searchads360/v0/services) are single JSON objects. `search` responses are JSON objects containing a `results` array with your query's result set.\n\nIdentifiers are transformed from *snake_case* (in protocol buffers) to\n*lowerCamelCase* in JSON. One notable caveat to this rule is when using\n`search` or `searchStream` to send [Search Ads 360 Query Language](/search-ads/reporting/query/query-language) queries. The query language itself uses snake case, regardless of which\ninterface you're using. However, the results of a query in REST are returned as\nnormal JSON objects and have their identifiers in lowerCamelCase.\n\nFor example, a query to fetch a list of active keywords in an account uses\nsnake case inside the query itself (`ad_group_criterion`, not `adGroupCriterion`): \n\n```http\nPOST /v0/customers/\u003cvar translate=\"no\"\u003eCUSTOMER_ID\u003c/var\u003e/searchAds360:searchStream HTTP/1.1\nHost: searchads360.googleapis.com\nContent-Type: application/json\nAuthorization: Bearer \u003cvar translate=\"no\"\u003eACCESS_TOKEN\u003c/var\u003e\n\n{\n \"query\": \"SELECT ad_group_criterion.keyword.text\n FROM ad_group_criterion\n WHERE ad_group_criterion.type = 'KEYWORD'\n AND ad_group_criterion.status = 'ENABLED'\"\n}\n```\n\nHowever, the response is a JSON representation of the objects (wrapped in a JSON\narray since this request uses `searchStream`) and uses the camelCase identifier\n`adGroupCriterion` instead: \n\n```javascript\n[\n {\n \"results\": [\n {\n \"adGroupCriterion\": {\n \"resourceName\": \"customers/1842689525/adGroupCriteria/55771861891~10003060\",\n \"keyword\": {\n \"text\": \"pay per click\"\n }\n }\n },\n ...\n ]\n }\n]\n```"]]