将带有项目的大括号字符串的 Google Admin SDK 的响应转换为多维数组

Converting the response of the Google Admin SDK with curly-brace strings with items into a multidimensional array

我有从 G Suite Admin SDK 中获取的数据,如下所示:

[{orgUnitPath=/Test, kind=admin#directory#orgUnit, blockInheritance=false, name=No Public Sharing, description=, etag="string", orgUnitId=id:00000, parentOrgUnitPath=/, parentOrgUnitId=id:111111}, ...]

如何将其转换成这样的数组:

[[[orgunitpath, test],[orgunitid,000000]],[[orgunitpath, test],[orgunitid,000000]],[[orgunitpath, test2],[orgunitid,222222]],[[orgunitpath, test],[orgunitid,222222]]]

我最终希望将此数据导入 AppMaker 中的 SQL 数据源。

您可以使用 Array#map

轻松做到这一点

片段:

var res; //[{orgUnitPath:/Test, orgUnitId:id:00000, parentOrgUnitPath=/, parentOrgUnitId=id:111111}, ...]
var array=res.map(function(obj){
    return [['orgunitpath', obj['orgUnitPath']],['orgunitid',obj['orgUnitId']]]
})