first create a mapper :

import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper mapper = new ObjectMapper();

As Array:

MyClass[] myObjects = mapper.readValue(json, MyClass[].class);

As List:

List<MyClass> myObjects = mapper.readValue(jsonInput, new com.fasterxml.jackson.core.type.TypeReference<List<MyClass>>(){});

Another way to specify the List type:

List<MyClass> myObjects = mapper.readValue(jsonInput, mapper.getTypeFactory().constructCollectionType(List.class, MyClass.class));

相关文章:

  • 2021-11-20
  • 2021-08-15
  • 2021-10-31
  • 2022-01-02
  • 2021-10-31
  • 2021-07-01
  • 2021-04-05
  • 2021-04-30
猜你喜欢
  • 2021-05-25
  • 2021-11-05
  • 2022-12-23
  • 2021-11-28
  • 2021-12-07
  • 2021-10-25
  • 2022-03-02
相关资源
相似解决方案