Let's start with three text files that represent typical JSON-like mappings:
In melons_raw.json, we have a JSON entry per line. Each line is a piece of JSON that's independent of the previous line but has the same schema. In melons_array.json, we have a JSON array, and in melons_map.json, we have a JSON that fits well in a Java Map.
For each of these files, we have a Path, as follows:
Path pathArray = Paths.get("melons_array.json");
Path pathMap = Paths.get("melons_map.json");
Path pathRaw = Paths.get("melons_raw.json");
Now, let's take a look at three dedicated libraries for reading the contents of these files as Melon instances:
public class Melon {
private String type;
private int weight;
// getters and setters omitted for brevity
}