In the set up section we borrowed json snippet from json.org example that will be used in the each of the snippets below.
Setup
JSON to Map
First initializing jackson's object mapper is the heart of jackson as it provides functionality for converting between Java objects and matching JSON constructs. Next we will read the sameJson value from above and pass a TypeReference into an overloaded readValue method. TypeReference is a class used used for obtaining full generics type information and an additional constructor mapper.readValue(src, Map.class) but you get a nasty check style error. Finally we will assert that the map has the following keys using hamcrest.
Java map to json
Flipping the snippet above around we will create a map object that resembles the same json value above. Instead of reading the value we will call writeValueAsString which will return the map as json in a java string.