Jackson Glossary: ObjectWriter
Package: org.codehaus.jackson.map
Jar: jackson-mapper
Role
This is a fully thread-safe, configured object that can be used to invoke serialization functionality that ObjectMapper offers (and in some cases features mapper does not offer).
Compared to ObjectMapper, configuration is done using chainable "fluent"-style configuration calls which will create new ObjectWriter instances and never change current instance (instances are immutable). This is what fully guarantees thread-safety, so that instances can be shared as well as used as "blueprints" in cases where alternate configurations are needed.
Usage
1 ObjectMapper mapper = new ObjectMapper();
2 // we want to use JSON View "MyView" for serialization, so:
3 ObjectWriter writer = mapper.viewWriter(MyView.class);
4 // and could also do other configuration...
5 String json = writer.writeValueAsString(new MyBean());
Related types
ObjectMapper is used to create instances
ObjectReader is the counterpart used for reading (deserialization)
Back to Jackson Term Glossary
