0

我正在尝试使用正则表达式将返回的 JSON 文件转换为使用[]not的单独对象,()这样我就可以从这些对象中的每一个中推出一个 id。我能够让初始 JSON 对象返回我需要将这些对象转换为数组。

参考:谷歌APP脚本获取属性

JS

   var GetShapeProps = [{
({
  id: "6:3",
  absoluteBoundingBox: [{
    x: -406,
    y: -274,
    width: 437,
    height: 56
  })
}),
({
  id: "10:3",
  absoluteBoundingBox: [{
    x: -406,
    y: -201,
    width: 437,
    height: 56
  })
}),
({
  id: "10:4",
  absoluteBoundingBox: [{
    x: -406,
    y: -122,
    width: 437,
    height: 56
  })
}),
({
  id: "10:5",
  absoluteBoundingBox: [{
    x: -406,
    y: -28,
    width: 437,
    height: 56
  })
}]


function prop1(obj1, getFrameProps, b, args){
  function prop2(obj1, getFrameProps, keys, b, kind) {
    var GetShapesProps = GetFrammeProps;
    obj1 = PropertiesService.GetShapesProps();

    // Sets several script properties, then retrieves them and logs them.
    GetShapesProaps = GetShapesProaps.getProperties();
    for (var id in GetShapesProaps) {
      if (id > GetShapesProaps) {
        var newObject = (kind, GetShapesProaps[id]);
      }
    }
  }
}

输出环:

[id: "6:3"]

[{ x: -406,
y: -274,
 width: 437,
 height: 56}]

返回错误

TypeError: Cannot find function replace in object 
[object Object],[object Object],
[object Object],[object Object],
[object Object],[object Object].

在此处输入图像描述

4

0 回答 0