【发布时间】:2022-01-22 22:55:59
【问题描述】:
我正在尝试从 Podio Workflow Automation 中的 Google People API 调用中提取地址数据。我正在成功提取除地址之外的所有其他数据。
情况 - 如果我只请求姓名,我可以提取每个单独的姓名字段,但如果我将地址添加到请求中,我将无法再提取姓名字段或地址字段。如果我只请求地址,我无法提取地址字段。
由于某种原因,包括地址数据似乎破坏了 JSON..
仅请求姓名数据,我得到:
{
"resourceName": "people/c2138163302931177819",
"etag": "%EgUBAi43PRoEAQIFByIMT1hSSUpZWTVuMFk9",
"names": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "1dac48320efd215b"
}
},
"displayName": "xx xxxxx xxxxxx",
"familyName": "xxxxxx",
"givenName": "xxxxx",
"honorificPrefix": "xx",
"displayNameLastFirst": "xxxxxx, xx xxxxx",
"unstructuredName": "xx xxxxx xxxxxx"
}
]
}
请求姓名和地址数据,我得到:
{
"resourceName": "people/c2138163302931177819",
"etag": "%EggBAgwQLjc9QBoEAQIFByIMT1hSSUpZWTVuMFk9",
"names": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "1dac48320efd215b"
}
},
"displayName": "xx xxxxx xxxxxx",
"familyName": "xxxxxx",
"givenName": "xxxxx",
"honorificPrefix": "xx",
"displayNameLastFirst": "xxxxxx, xx xxxxxx",
"unstructuredName": "xx xxxxx xxxxxx"
}
],
"addresses": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "1dac48320efd215b"
}
},
"formattedValue": "xxxxxxx\nSouthampton, England xxxxxxx\nUnited Kingdom",
"streetAddress": "xxxxxxx",
"city": "Southampton",
"region": "England",
"postalCode": "xxxxxxx",
"country": "United Kingdom",
"countryCode": "GB"
}
]
}
对我来说,这在结构上看起来没有什么不同,但是当我将其更改为此处的代码时,它无法正确识别后一个..
在 Podio 中,我对响应进行 base64 编码,然后作为示例提取我使用的名字:
json_decode(base64_decode([(Variable) google_array]))->{'names'}[0]->{'givenName'}
对于我正在使用的城市
json_decode(base64_decode([(Variable) google_array]))->{'addresses'}[0]->{'city'}
如果我只请求姓名详细信息,但如果它还包含地址详细信息,则提取名称可以正常工作。似乎只有地址会造成此问题。我无法提取任何地址详细信息。
【问题讨论】:
-
看这里的代码我想知道是不是出现在地址 formattedValue 字段中的 /n
标签: json podio google-people-api