0

I'm trying to convert a json string to a list of objects in java.

code:

List<StopEta> list = mapper.readValue(string, new TypeReference<List<Pairs>>(){});

error:

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

string equals to:

{"pairs":[{"pair1":2,"pair2":2},{"pair1":1,"pair2":1}]}
Jens
  • 67,715
  • 15
  • 98
  • 113
  • 2
    Possible duplicate of [Can not deserialize instance of java.util.ArrayList out of START\_OBJECT token](https://stackoverflow.com/questions/20837856/can-not-deserialize-instance-of-java-util-arraylist-out-of-start-object-token) – soorapadman Jan 07 '19 at 11:57
  • 1
    It's not a list resp. array at the root of the JSON ... – UninformedUser Jan 07 '19 at 11:57
  • try gson api's check this https://stackoverflow.com/questions/5554217/google-gson-deserialize-listclass-object-generic-type – Lokesh Yadav Jan 07 '19 at 12:05

0 Answers0