Stage 6 · Lesson 3 of 8
Files and JSON with Jackson
Java has no parser in its , so most projects add or Gson. With Jackson, an ObjectMapper turns JSON text into your own classes or , and back again. Turning objects into text and back like this is called serialisation.
mapper.readValue(file, Entry[].class) reads, and mapper.writerWithDefaultPrettyPrinter().writeValue(file, entries) writes. Records make good data classes for this. Missing and unknown fields are the common failure.
A missing field quietly becomes null or zero. How unknown fields are treated depends on the library and its settings. So validate after loading instead of trusting the file.
For , use Path and Files from java.nio.file and handle IOException. Keep loading and saving in one class, so the core logic works on plain objects.
A question to check yourself, an AI practice session and 3 cheat sheet entries come when you add the roadmap to your account. Add it
Resources for this stage
Start with
- GitHub repoFreeProject Based Learning
Community maintained · Beginner
Follow one guided build in your language, then build your own without a guide
Keep handy
Also worth your time
How to present each project: the problem, stack, challenges and results
- Build Your Own XGo deeper
When you want a harder build: a shell, a key-value store or a tiny Git, from scratch