MApping JSON to array return null

帅比萌擦擦* 提交于 2021-02-11 13:21:57

问题


When I use this line I get :

AudDto[] auditDtos = objectMapper.readValue(responseBodyAsString, AudDto[].class);

I got : com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `` out of START_OBJECT token

So I add this line : objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

After that I got : com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “errMsg”

So I used : objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

Now I have no exceptions or errors, but the value that return is null.

[{"time":0,"type_key":null,"type_description":null},{"time":0,"type_key":null,"type_description":null},{"time":0,"type_key":null,"type_description":null}]

what the problem could be here ? how it can be solved ?

来源:https://stackoverflow.com/questions/65396104/mapping-json-to-array-return-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!