我无法在Google data Studio中为嵌套的JSON数据建模。我在"地址">字段。
JSON数据:
{
"data": [
{
"id": 37314,
"first_name": "Lio",
"last_name": "Mino",
"addresses": [
{
"id": 7834,
"city": "Washington",
"primary": 1,
},
{
"id": 5034,
"city": "New yourk",
"primary": 1,
}
]
},
...
]
}
如果没有addresses
字段,一切都可以正常工作。但我也需要返回地址。我希望我能很好地解释情况。
function getAddresses() {
const s = '{"data":[{"id":37314,"first_name":"Lio","last_name":"Mino","addresses":[{"id":7834,"city":"Washington","primary":1},{"id":5034,"city":"Newyourk","primary":1}]}]}';
const obj = JSON.parse(s);
const o=obj.data.map(e=>{return e.addresses.map(a=>{return a})});
Logger.log(JSON.stringify(o))
}
Execution log
6:45:15 PM Notice Execution started
6:45:15 PM Info [[{"id":7834,"city":"Washington","primary":1},{"id":5034,"city":"Newyourk","primary":1}]]
6:45:15 PM Notice Execution completed