如何在google sheet appscript中读取多维JSON数据?
How to read multidimensional JSON data in google sheet appscript?
如何在 google 电子表格中读取此类 json 数据,就像我想要 ID:12311 的职业一样?
{
"user": [
{
"id": 12311,
"name": "Deffy doof",
"profession": "Photographer"
},
{
"id": 18341,
"name": "John Smith",
"profession": "Developer"
}
]
}
解决方案:
由于这是一个对象数组,您可以使用数组表示法引用元素,例如,拉取“摄影师”:
data.user[0].profession
样本:
如果只知道唯一ID不知道索引,可以先过滤数组,再获取元素。
var array = data.user.filter(function b(e) { return e.id == 12311 });
console.log(array[0].profession);
参考文献:
如何在 google 电子表格中读取此类 json 数据,就像我想要 ID:12311 的职业一样?
{
"user": [
{
"id": 12311,
"name": "Deffy doof",
"profession": "Photographer"
},
{
"id": 18341,
"name": "John Smith",
"profession": "Developer"
}
]
}
解决方案:
由于这是一个对象数组,您可以使用数组表示法引用元素,例如,拉取“摄影师”:
data.user[0].profession
样本:
如果只知道唯一ID不知道索引,可以先过滤数组,再获取元素。
var array = data.user.filter(function b(e) { return e.id == 12311 });
console.log(array[0].profession);