#Help - Java HashMap cannot be cast to class Author

1 messages ยท Page 1 of 1 (latest)

lunar roverBOT
#

<@&987246399047479336> please have a look, thanks.

lunar roverBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

plush yew
#

When i request directly Author with

{
  "name": "Auteur 1",
  "mail": "[email protected]"
}

work correctly

lunar roverBOT
dense igloo
#

what kind of List is this?

plush yew
#

it's just default list, here it's ArrayList

dense igloo
#

getFirst?

#

ah prob using java 21 right?

plush yew
#

yep ... forcing by teacher ๐Ÿ˜ข

dense igloo
#

its good lol

plush yew
#

but i don't understand the probleme, why java detect HashMap when i request by project

lunar roverBOT
#

Changed the category to Frameworks.

#

<@&987246452180930620> please have a look, thanks.

echo shore
#

not just the first line

hazy burrow
plush yew
#

ok sry for waiting so long

#

i've resolve my main problem, just to need to cast with a json (use jackson)

#
List<Author> deserializedAuthors = new ArrayList<>();

for (var i = 0; i < project.authors.size(); i++) {
    Author author = new ObjectMapper().convertValue(project.authors.get(i), Author.class);
    deserializedAuthors.add(author);
}

and it's work fine for me !

#

thx anyway !

agile light
#

You get every author json separately?

#

If it is present in the same file you can convert it to a list directly too