code: function cleanItem2(value, parent) {
       
          if (Array.isArray(value)) {
              newvalue = [];
  
              value.forEach(function (item) {
                  newvalue.push(cleanItem2(item, parent + ".values"));
              })
  
              return newvalue;
          }
  
          if ((typeof value !== "object") || (value == null)) {
              return value;
          }
  
          var newvalue = null;
  
          var isParentKey = (["surveys", "videos"].indexOf(parent) > -1)
          var parentComponents = parent.split(".");
  
          var isParentKey = isParentKey || (parentComponents.length == 2 && (["randomSelections"].indexOf(parentComponents[0]) > -1))
  
          Object.keys(value).forEach(function (key) {
  
              if (isKey(key) || value[key]["id"] == key || isParentKey) {
  
                  if (newvalue == null)
                      newvalue = [];
                  else if (!Array.isArray(newvalue)) {
  
                      if (Object.keys(newvalue).length !== 1)
                          throw new Error("Not an array" + JSON.stringify(newvalue));
  
                      var prevkey = Object.keys(newvalue)[0];
                      var prevobj = newvalue[prevkey];
                      newvalue = [Object.assign({ id: prevkey }, prevobj)];
                      cacheid(prevkey, parent)
                  }
  
                  var obj = cleanItem2(value[key], parent + "." + key);
  
                  if (Array.isArray(obj)) {
                      obj = { id: key, values: obj }
                      cacheid(key, parent)
                      newvalue.push(obj);
                  } else if (typeof obj !== "object") {
                      obj = { id: key, value: obj };
                      cacheid(key, parent)
                      newvalue.push(obj);
                  } else if (obj) {
                      newvalue.push(Object.assign({ id: key }, obj));
                      cacheid(key, parent)
                  }
  
              } else {
                  newvalue = newvalue || {};
                  newvalue[key] = cleanItem2(value[key], parent + "." + key);
              }
          });
  
          return newvalue;
      }
docs: Add Ids