September 2019
Intermediate to advanced
816 pages
18h 47m
English
Java EE 8 comes with a JAXB-like, declarative JSON binding called JSON-B (JSR-367). JSON-B is consistent with JAXB and other Java EE/SE APIs. Jakarta EE takes Java EE 8 JSON (P and B) to the next level. Its API is exposed via the javax.json.bind.Jsonb and javax.json.bind.JsonbBuilder classes:
Jsonb jsonb = JsonbBuilder.create();
For deserialization, we use Jsonb.fromJson(), while, for serialization, we use Jsonb.toJson():
Melon[] melonsArray = jsonb.fromJson(Files.newBufferedReader( pathArray, StandardCharsets.UTF_8), Melon[].class);
List<Melon> melonsList = jsonb.fromJson(Files.newBufferedReader( pathArray, StandardCharsets.UTF_8), ...