Jackson Glossary: JsonGenerator
Package: org.codehaus.jackson
Jar: jackson-core
Role
This is the main "writer" class of core Jackson package. It offers a high-performance incremental, "streaming" (see JacksonStreamingApi) method for writing JSON content.
Instances are meant to be used from a single thread (they are not thread-safe); and they are not reusable (there are no methods for reset instances -- there are no performance benefits from doing so because reuse of underlying buffers is implemented separate from life-cycle of generator instances) by design.
Usage
Instances are created by JsonFactory, either directly, or through higher-level abstractions like ObjectMapper.
JacksonStreamingApi contains simple examples of usage.
Related
Just like for JsonParser (its reader-side counterpart), there exist multiple non-JSON-producing variants of JsonGenerator. For example, both XmlFactory and SmileFactory offer respective writers that produce data in alternative formats (XML and Smile, respectively).
Most of configuration is by enabling/disabling JsonGenerator.Feature options.
Back to Jackson Term Glossary
