Can not deserialize instance of scala.collection.immutable.List$ out of START_ARRAY token
时间: 2024-01-31 16:59:21 浏览: 96
This error message typically occurs when you are trying to deserialize a JSON array into a Scala List using a library such as Jackson or Gson. The error message is telling you that the library is expecting a JSON object but instead, it is receiving a JSON array.
To fix this issue, you need to ensure that the JSON data is in the correct format for deserialization. If you are using Jackson, you can annotate the field or constructor parameter with @JsonDeserialize(as = List.class) to explicitly tell the library to deserialize the JSON array into a List. If you are using Gson, you can use the TypeToken class to specify the type of the object you want to deserialize.
Another possible solution is to modify the JSON data to match the expected format for deserialization. For example, if you have an array of objects, you can wrap it in a JSON object with a key that represents the name of the array. This will allow you to deserialize the JSON data into a map, where the key maps to a List of objects.
阅读全文