Это мой JsonObject
JSONObject input = new JSONObject("{\n" +
" \"ColumnNames\":[\"col1\", \"col2\", \"col3\", \"col4\", \"col5\"]\n" +
"}");
Мой класс POJO
public class RequestClass {
private List<String> ColumnNames;
public void setColumnNames(List<String> ColumnNames) {
this.ColumnNames = ColumnNames;
}
public List<String> getColumnNames() {
return this.ColumnNames;
}
}
Попытка преобразовать JsonObject в объект класса pojo с помощью ObjectMapper, как показано ниже -
ObjectMapper mapper = new ObjectMapper();
//mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
RequestClass request = null;
try {
request = mapper.readValue(input.toString(), RequestClass.class);
} catch (Exception e) {
e.printStackTrace();
}
Получение исключения в выводе
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ColumnNames" (class RequestClass), not marked as ignorable (one known property: "columnNames"])
at [Source: {"ColumnNames":["col1","col2","col3","col4","col5"]}; line: 1, column: 17] (through reference chain: RequestClass["ColumnNames"])