code: private void setCustomVariable(String parameter, CustomVariable customVariable, Integer index){
          CustomVariableList cvl = (CustomVariableList)parameters.get(parameter);
          if (cvl == null){
              cvl = new CustomVariableList();
              parameters.put(parameter, cvl);
          }
          
          if (customVariable == null){
              cvl.remove(index);
              if (cvl.isEmpty()){
                  parameters.remove(parameter);
              }
          }
          else if (index == null){
              cvl.add(customVariable);
          }
          else {
              cvl.add(customVariable, index);
          }
      }
docs: Store a value in a json object at the specified parameter.
  @param parameter the parameter to store the json object at
  @param key the key of the value.  Cannot be null
  @param value the value.  Removes the parameter if null