pawiromitchel
1/31/2018 - 6:18 PM

Reset JSON Array dynamically

Reset JSON Array dynamically

resetJsonArray(json){
    let temp = [];
    for (var i in json) {
      var key = i;
      var val = json[i];
      for (var j in val) {
        var sub_key = j;
        var sub_val = val[j];
        temp.push(sub_key);
      }
    }

    json.map((value, index) => {
      value[temp[index]] = 0;
    });

    return json;
  }