ObjectMapper

Jackson's main class, which converts objects to JSON with writeValueAsString and JSON to typed objects with readValue, following its configured rules.

In more detail

An ObjectMapper is expensive to build and safe to share, so an application should create one configured instance and inject it wherever needed; Spring Boot does this for you. Tests should use the same configuration so they assert the real wire format.

Examples

String json = mapper.writeValueAsString(message);
Message m = mapper.readValue(json, Message.class);

Related terms

Taught in

References