How to use Jackson to deserialise an array of objects

前端 未结 8 1315
梦谈多话
梦谈多话 2020-11-21 22:58

The Jackson data binding documentation indicates that Jackson supports deserialising \"Arrays of all supported types\" but I can\'t figure out the exact syntax for this.

8条回答
  •  故里飘歌
    2020-11-21 23:21

    First create an instance of ObjectReader which is thread-safe.

    ObjectMapper objectMapper = new ObjectMapper();
    ObjectReader objectReader = objectMapper.reader().forType(new TypeReference>(){});
    

    Then use it :

    List result = objectReader.readValue(inputStream);
    

提交回复
热议问题