Google 脚本 - 解析 json 响应

Google script - parse json response

这是我要解析的 json 响应(来自我的多项选择字段 jsfiddle):

{"selected":true,"disabled":false,"text":"Ctr","id":"Ctr","title":"","_resultId":"select2-selectcountry-result-je97-Ctr","element":{}},

{"selected":true,"disabled":false,"text":"Title Part1","id":"TitlePart1","title":"","_resultId":"select2-selectcountry-result-uv7s-TitlePart1","element":{}},

{"selected":false,"disabled":false,"text":"Milan","id":"Milan","_resultId":"select2-selectcountry-result-bmba-Milan","element":{}}]

我需要得到:{"id":value},{"id":value},{"id":值} ...

{id:Ctr},{"id":"TitlePart1"},{"id":"Milan} ...

为了达到这个结果,我使用了这段代码:

var response = (JSON.stringify($('#selectcountry').select2('data')) );        
var json = JSON.parse(response);
        var dataSet = json;
        var row = [],
        data;
       for(var i in json){
       data = dataSet[i];
       row.push({'id': json[i].id})
       }

   sheet.getRange(6,1).setValue(row);

但是这样我只得到第一个id:value:

{id:Ctr}

有什么帮助吗?

谢谢

var s='[{"selected":true,"disabled":false,"text":"Ctr","id":"Ctr","title":"","_resultId":"select2-selectcountry-result-je97-Ctr","element":{}},{"selected":true,"disabled":false,"text":"Title Part1","id":"TitlePart1","title":"","_resultId":"select2-selectcountry-result-uv7s-TitlePart1","element":{}},{"selected":false,"disabled":false,"text":"Milan","id":"Milan","_resultId":"select2-selectcountry-result-bmba-Milan","element":{}}]';

function findId() {
  var d=JSON.parse(s);
  var ids=[];
  d.forEach(function(o){
    ids.push(o.id);
  });
  Logger.log(ids);
  //Add this
  SpreadsheetApp.getActiveSheet().getRange(1,1,1,3).setValues([ids]);
}