Garmaine Staff asked 2 years ago

I have written some code which saves the contents of a List<Class> to a JSON file, which looks kinda like this:

{ "firstName": "Name", "lastName": "LastName", "Email": "Email" } { "firstName": "Name2", "lastName": "LastName2", "Email": "Email2" }

Now I'm trying to input this file into my program, which works but only the first JSON Object is being returned. This is my code:

ObjectMapper mapper = new ObjectMapper();
JsonNode readFile = mapper.readTree(new File("path/to/file.json"));

How can I read the full JSON file and how can I add the contents of it to the same List mentioned above? Every tutorial etc. I stumble upon only explains this using a single object. Thank you!