java - ObjectMapper fails to deserialize - cannot deserialize instance of .... out of START_ARRAY token -
I have a Jason:
{"games": [{id: "", "To": "425364_456 @ localhost", "to": "localhost @ 788295_456", "token": "Exxvustvoxo 5zghlgjcapmq5tirae", "desc": "6 CEF9 / YEFIUPLLOBBT 9PC799J JK6TG6 NKA4HE = "," Timestamp ": 1412806372232}," "": "" "" "", from ":" 425364_456 @lostalhost "," to ":" 788295_456 @ localhost "," Token ":" Exxvistvoxo 5zghlgjcapmq5tirae "," desc ":" z / ww2xroGoIG5hrgiWsU1P8YHrv4SxiYHHoojzt9tdc = "," timestamp ": 1412806373651}]} < P> I'm trying to deserialize it with an object with the ObjectMapper . Basically as you can see, this is a list of games. I have There are classes:
@JesRootnom (value = "games") public class game Jason {Private list> game> games; // getters and setters} < / Pre> The game class is here:
public class game {Private string ID; Private string from; Private string; Private string token; Give a personal string; Private quick timestamp; // getters and setters} In my code, ObjectMapper is doing this: ObjectMapper mapper = New ObjectMapper ( ); Mapper.configure (DeserializationFeature.UNWRAP_ROOT_VALUE, true); GameJason Jason = Mapper Reed Value (new file intstream (gamesfile), gamejessen.class); Then I receive this error:
com.games.collection.GameJson out of START_ARRAY token I am trying to do this in various ways, but with no luck coming out. Can anyone help?
Thank you!
get rid of @JsonRootName (value = "games") Identifies the annotated type of annotation as the target for the JSON object "games" . In your case, this is a JSON array. An array in your game Jason class can not be deserialized. , you have to remove the configuration that enables @JsonRootName . Mapper Configure (DeserializationFeature.UNWRAP_ROOT_VALUE, true);
Comments
Post a Comment