Jackson Glossary: JsonFactory
Package: org.codehaus.jackson
Jar: jackson-core
Role
This is the main factory class for core package, which can be used to instantiate JsonParser and JsonGenerator instances, as well as defining default settings for those instances.
Instances are fully thread-safe when "configure-then-use" pattern is used (i.e. configuration is not thread-safe but usage is).
Usage
This class can be instantiated and used directly, when using JacksonStreamingApi; if so, you will do:
1 JsonFactory factory = new JsonFactory();
2 factory.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false); // all configuration before use
3 JsonParser jp = factory.createJsonParser(new FileInputStream("content.json"));
4 // ... then use
but more commonly it is only indirectly used via ObjectMapper instance, i.e. not visible to application code.
Sub-types
MappingJsonFactory is a simple extension that is always linked to ObjectCodec (typically an ObjectMapper) needed to use "JsonParser.readValueAs()"
Back to Jackson Term Glossary
