Hope this helps, In my case I used getTaskFormData
to get all form fields and then iterate to get values manually to extract what I need.
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
Gson gson = new Gson();
String result = "";
ArrayList<Map<String, Object>> listForm = new ArrayList<Map<String, Object>>();
List<FormField> lf = processEngine.getFormService().getTaskFormData(**<taskId>**).getFormFields();
for (Iterator<FormField> iterator = lf.iterator(); iterator.hasNext();) {
Map<String, Object> temp = new HashMap<String, Object>();
FormField formField = iterator.next();
temp.put("id", formField.getId());
temp.put("label", formField.getLabel());
temp.put("prop", formField.getProperties()); //extra properties like enum map
temp.put("type", formField.getType());
temp.put("typeName", formField.getTypeName());
temp.put("value", formField.getValue().getValue());
temp.put("validations", formField.getValidationConstraints());
listForm.add(temp);
}
System.out.println(gson.toJson(listForm));
result = gson.toJson(listForm);
//result is the json of the whole form for task