-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.IllegalArgumentException: Cannot deserialize value of type java.util.ArrayList<RetInfArryDTO> from Object value (token
JsonToken.START_OBJECT`)
#630
Comments
Wrong repo, will transfer. |
Ok, there are quite a few challenges for reproduction here. For starters, when testing, PLEASE NEVER DISABLE Second: although use of Lombok is fine with Jackson, and should work, test reproductions should not use Lombok since its bytecode post-processing makes it difficult to know what is happening. Third: Jackson does not actually support deserialization for all kinds of XML representations: it specifically aims to support use case of "reading what it writes": so, if you start with Java objects, serialize as XML, it should also be able to read XML back into same Java objects. Fourth: your attempt to read XML as I hope this helps. |
OK ,thank you very much, let me know more about jackson 👍 It look like that the |
If you want to use some other encoding, you will need to create |
@cowtowncoder |
What do issues say? If there is progress, solution, there will be comments. #355 in particular is closed: there is no defect, although users are unhappy about having to include namespace with all namespace declarations. #324 would be great to support, but as things are it is not easy to do: partly since there is no way to specify namespace for Type Ids (via Although... perhaps, just perhaps, there could be a feature to force simple name of |
Added my notes on #324: maybe I'll play with that later tonight. |
Search before asking
Describe the bug
I use jackson-dataformat-xml to deserialize XML , but it throws exception :
Exception in thread "main" java.lang.IllegalArgumentException: Cannot deserialize value of type
java.util.ArrayList<RetInfArryDTO>
from Object value (tokenJsonToken.START_OBJECT
)at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: AnRspDTO["SysHead"]->SysHeadRspDTO["RetInfArry"])
It look like thak jackson unrecognize this type of XML format data , could not treat the array in XML as real array to deserialize , but I think it is a kind of common XML data which contain array type, isn't it ?
I tried annotation like @JsonDeserialize(contentAs = AddrInfArryDTO.class), @JsonAlias({ "IdInfArry", "IdInfArry.array" }), but it did not work for me !
Q1: Is anyone know how to solve this problem?
Q2: If I must use custom JsonDeserializer to solve , how can I get the
elementType
below ?could not get it from both jsonParser and deserializationContext, and i don't want to write hard code , give exactly elementType here, because too must DTO to be deserialized , write a general custom JsonDeserializer is very necessary!Here below is my XML data to be deserialized and its DTO object :
(1)XML data like this :
(2)Here is my DTO , XML deserialize object :
Version Information
pom dependency , current steady version 2.16.0 could not solve the problem too
Reproduction
<-- Any of the following
-->
Expected behavior
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: