Source:
private static void parseQuestionAnswer(JSONObject obj, FormEntryPrompt prompt){ IAnswerData answerValue = prompt.getAnswerValue(); if (answerValue == null){ obj.put("answer", JSONObject.NULL); return; } switch(prompt.getDataType()) { case Constants.DATATYPE_NULL: case Constants.DATATYPE_TEXT: obj.put("answer", answerValue.getDisplayText()); return; case Constants.DATATYPE_INTEGER: obj.put("answer", (int)answerValue.getValue()); return; case Constants.DATATYPE_LONG: case Constants.DATATYPE_DECIMAL: obj.put("answer", (double)answerValue.getValue()); return; case Constants.DATATYPE_DATE: obj.put("answer", (DateUtils.formatDate((Date)answerValue.getValue(), DateUtils.FORMAT_ISO8601))); return; case Constants.DATATYPE_TIME: obj.put("answer", answerValue.getDisplayText()); return; case Constants.DATATYPE_DATE_TIME: obj.put("answer", ((Date)answerValue.getValue()).getTime()/1000); return; case Constants.DATATYPE_CHOICE: Selection singleSelection = ((Selection)answerValue.getValue()); singleSelection.attachChoice(prompt.getQuestion()); obj.put("answer", ((Selection)answerValue.getValue()).index + 1); return; case Constants.DATATYPE_CHOICE_LIST: Vector<Selection> selections = ((SelectMultiData)answerValue).getValue(); JSONArray acc = new JSONArray(); for(Selection selection: selections){ selection.attachChoice(prompt.getQuestion()); int ordinal = selection.index + 1; acc.put(ordinal); } obj.put("answer", acc); return; case Constants.DATATYPE_GEOPOINT: double[] coords = ((GeoPointData)prompt.getAnswerValue()).getValue(); obj.put("answer", Arrays.copyOfRange(coords, 0, 2)); return; } }

Target:
private static void parseQuestionAnswer(JSONObject obj, FormEntryPrompt prompt) { IAnswerData answerValue = prompt.getAnswerValue(); if (answerValue == null) { obj.put("answer", JSONObject.NULL); return; } switch (prompt.getDataType()) { case Constants.DATATYPE_NULL: case Constants.DATATYPE_TEXT: obj.put("answer", answerValue.getDisplayText()); return; case Constants.DATATYPE_INTEGER: obj.put("answer", (int) answerValue.getValue()); return; case Constants.DATATYPE_LONG: case Constants.DATATYPE_DECIMAL: obj.put("answer", (double) answerValue.getValue()); return; case Constants.DATATYPE_DATE: obj.put("answer", (DateUtils.formatDate((Date) answerValue.getValue(), DateUtils.FORMAT_ISO8601))); return; case Constants.DATATYPE_TIME: obj.put("answer", answerValue.getDisplayText()); return; case Constants.DATATYPE_DATE_TIME: obj.put("answer", ((Date) answerValue.getValue()).getTime()); return; case Constants.DATATYPE_CHOICE: Selection singleSelection = ((Selection) answerValue.getValue()); singleSelection.attachChoice(prompt.getQuestion()); obj.put("answer", ((Selection) answerValue.getValue()).getTouchformsIndex()); return; case Constants.DATATYPE_CHOICE_LIST: Vector<Selection> selections = ((SelectMultiData) answerValue).getValue(); JSONArray acc = new JSONArray(); for (Selection selection : selections) { selection.attachChoice(prompt.getQuestion()); int ordinal = selection.getTouchformsIndex(); acc.put(ordinal); } obj.put("answer", acc); return; case Constants.DATATYPE_GEOPOINT: GeoPointData geoPointData = ((GeoPointData) prompt.getAnswerValue()); double[] coords = new double[]{geoPointData.getLatitude(), geoPointData.getLongitude()}; obj.put("answer", coords); return; } }