ImportJson Funtion检索不同位置的列

时间:2018-09-06 16:40:17

标签: javascript arrays json multidimensional-array google-apps-script

我正在使用一个函数来获取和处理JSON对象,并将信息显示在Google电子表格中。工作正常。

我要在5个工作表中使用查询中的不同过滤器来调用该函数。

我遇到的问题是每个页面上的属性顺序都会更改。 在某些电子表格中,“名称”在A列中,在另一个电子表格中在D列中,与其他列相同。

代码使用的是多维数组,我想知道是否可以固定属性在数组上的位置,所以Name总是显示在每一页的同一列中。

我常用的脚本是:  https://github.com/bradjasper/ImportJSON

[{
        "_id" : {
            "$oid" : "2342hgiug2343242gi"
        },
        "ID" : "HHT-6",
        "Link" : "SomeLink",
        "Name" : "Some Description",
        "Type" : "Request",
        "Team" : null,
        "Release" : null,
        "Stage" : "Open",
        "Level" : null,
        "Labels" : "[3244234,234234;]",
        "Versions" : null,
        "Components" : null,
        "DevelopmentSize" : null,
        "Class of Service" : "Standard",
        "Resolution" : null,
        "Location" : null,
        "Main Category" : null,
        "First Category" : null,
        "Second Category" : null,
        "Key" : "HHT",
        "Created" : "2016-02-12"
    }
]

1 个答案:

答案 0 :(得分:0)

更新到最新版本

https://github.com/bradjasper/ImportJSON/blob/master/ImportJSON.gs

因此,要按请求的顺序返回路径,必须传递' allHeaders '选项参数。

=ImportJSON("https://jsonplaceholder.typicode.com/todos"; "/title,/invalidColumn,/completed"; "allHeaders")

观察 /invalidColumn 也将返回。