Answers for "how do ObjectMapper works for list"

3

objectmapper convert list of objects

List<MyClass> myObjects = mapper.readValue(jsonInput, new TypeReference<List<MyClass>>(){});
Posted by: Guest on December-03-2020
-2

convert json to object jackson

ObjectMapper objectMapper = new ObjectMapper();

String carJson =
    "{ \"brand\" : \"Mercedes\", \"doors\" : 5 }";

try {
    Car car = objectMapper.readValue(carJson, Car.class);

    System.out.println("car brand = " + car.getBrand());
    System.out.println("car doors = " + car.getDoors());
} catch (IOException e) {
    e.printStackTrace();
}
Posted by: Guest on June-22-2020

Code answers related to "how do ObjectMapper works for list"

Browse Popular Code Answers by Language