November 2017
Intermediate to advanced
420 pages
10h 29m
English
Sometimes, you may need to deal with highly dynamic JSON content where you may not be able to map data to a specific Java object, as the structure of the data changes dynamically. In such a scenario, you can use the simple binding APIs offered by the Jackson framework. You will use the Java maps, lists, strings, numbers, Booleans, and nulls for representing dynamic JSON data.
The following code snippet converts a JSON string into a map object. The com.fasterxml.jackson.core.type.TypeReference class is used for passing a generic type definition, which defines a type to bind to, as follows:
String jsonString = "{\" firstName\":\"John\",\"lastName\":\"Chen\"}"; ObjectMapper objectMapper = ...