List items = getListFromJson(path) - there will be convertation error. This code not working properly
@cellonlush55832 жыл бұрын
yes I am aware of it. The generic method won't work in that way. If you want to do that, use just readValue() method and specify class type. (you could also create your own customObjectMapper and extend the objectMapper.) It could be even simpler than that. Just a single line. Ex. ClassName varName = new CustomObjectMapper().readValue(new File("path"), ClassName.class); pretty straightforward. Thank you for comment.
@cellonlush55832 жыл бұрын
Check it out! better/simpler/easier way. kzbin.info/www/bejne/iGTKpJtmiK9piK8 You can do List items = getListFromJson(path); But you can't do Item item = items.get(0); and Item item = getListFromJson(path).get(0); It will throw class cast exception. There is actually easier way of doing it , but it is pretty similar to what I did in this video. So I just decided not to upload before. But I will upload it soon