使用 Jackson 解析 Json 文件时无法反序列化 parseJason 的实例

Can not deserialize instance of parseJason when using Jackson to parse the Json File

我有一个 Json 文件 :

[
{
      "name":"Move",
      "$$hashKey":"object:79",
      "time":11.32818,
      "endTime":18.615535
   },
   {
      "name":"First Red Flash",
      "$$hashKey":"object:77",
      "time":15.749153
   },
   {
      "name":"Pills",
      "subEventTypes":[
         "pull down bottle",
         "unscrew lid",
         "dump pills out",
         "screw lid on",
         "put bottle away"
      ],
      "$$hashKey":"object:82",
      "time":25.130175,
      "subEventSplits":[
         26.092057,
         27.425881,
         31.841594,
         34.268093
      ],
      "endTime":36.234827
   }


]

我尝试使用 Jackson 解析这个 Json 文件。 我写了下面的代码:

public class Holder{
        public Holder(){};
        //getter and setters

        String name;
        List<String> subEventTypes = new ArrayList<>();
        Double time;
        String $$hashKey;
        Double endTime;
        List<Double> subEventSplits = new ArrayList<>();

    }
class MapperClass{
    List<Holder> list = new ArrayList<>();
}

public static void main(String[] args) throws JsonProcessingException, IOException
{
    ObjectMapper mapper = new ObjectMapper();
    List<Holder>  list = mapper.readValue(new File("data.json"), mapper.getTypeFactory().constructCollectionType(
            List.class, Holder.class));

}

当我 运行 程序时,它显示了这个错误:“

No suitable constructor found for type [simple type, class parseJason$Holder]: can not instantiate from JSON object (need to add/enable type information?)

”。 我的代码有什么问题吗?或者我必须使用另一种方式来解析我的 Json 文件。

尝试

list = mapper.readValue(
                jsonString,
                objectMapper.getTypeFactory().constructCollectionType(
                        List.class, Holder.class));