code: public static <T> void convertJSONObjectToDirectoryObject(JSONObject jsonObject, T destObject) throws Exception {
  
          // Get the list of all the field names.
          Field[] fieldList = destObject.getClass().getDeclaredFields();
  
          // For all the declared field.
          for (int i = 0; i < fieldList.length; i++) {
              // If the field is of type String, that is
              // if it is a simple attribute.
              if (fieldList[i].getType().equals(String.class)) {
                  // Invoke the corresponding set method of the destObject using
                  // the argument taken from the jsonObject.
                  destObject
                          .getClass()
                          .getMethod(String.format("set%s", WordUtils.capitalize(fieldList[i].getName())),
                                  new Class[] { String.class })
                          .invoke(destObject, new Object[] { jsonObject.optString(fieldList[i].getName()) });
              }
          }
      }
docs: This is a generic method that copies the simple attribute values from an
  argument jsonObject to an argument generic object.
  
  @param jsonObject
  The jsonObject from where the attributes are to be copied.
  @param destObject
  The object where the attributes should be copied into.
  @throws Exception
  Throws a Exception when the operation are unsuccessful.