Jackson Glossary: ObjectWriter

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());


Back to Jackson Term Glossary


CategoryJackson

ObjectWriter (last edited 2010-12-08 21:03:51 by TatuSaloranta)

Copyright ©2009 FasterXML, LLC