When converting a Jackson JsonNode to a Java collection?
See question/answer below: https://stackoverflow.com/a/39237947/15435022
ObjectMapper mapper = new ObjectMapper(); // singleton in the project
...
JsonNode arrayNode = mapper.createArrayNode().add("one").add("two");
ObjectReader reader = mapper.readerFor(new TypeReference<List<Product>>() {});
List<String> list = reader.readValue(arrayNode);
Should ObjectReader for TypeReference, be a singleton within the project, or should it be redeclared everytime the method is called?
I already have ObjectMapper declared as singleton in project.
ObjectReader reader = mapper.readerFor(new TypeReference<List<Product>>() {});