JSTEP 6 - FasterXML/jackson-future-ideas GitHub Wiki
(Back to JSTEP page)
Tatu Saloranta (@cowtowncoder)
- 2025-01-02: Updates wrt "Text"->"String" changes
- 2024-11-20: updated with the current state
- 2024-06-02: updated with the current state
- 2021-02-05: create first version based on existing changes
Mostly complete but will remain until 3.0.0 release for possible additional renaming.
Due to historical reasons, naming of entities, methods and fields in Jackson is in places inconsistent and/or misleading. For example: since the original Jackson 1.0 only worked on JSON, term "Json" is included in many entity names, and even if Databind package is completely format-agnostic, naming there would suggest that things are very JSON-centric.
Similarly there are things that are referred using different terms in places. For example:
- Name used for key/value pairs of content Object Values (like JSON Objects in JSON input) are variously known as "properties" (mostly in databind) and "fields" (often in streaming core package).
- Term "Object" may refer to content Object Values (JSON Objects) and its in-memory representations (
ObjectNode
of Tree Model); but also to Java Objects. But Java Objects also also known as "POJOs" and "Beans" in other cases (in databind, mostly). - For databind, there was
DeserializationContext
for deserialization (reading Java Values out of token streams): but serialization side hadSerializerProvider
for similar context object
Although there has been progress over Jackson 2.x development cycle -- new abstractions, entities, methods, tend to be named with less issues -- backwards-compatibility prevents renaming in most cases.
But now that we are planning a major version, it is possible to make compatibility-breaking changes. Benefits of such renaming need to be balanced with the added effort for developers; benefits of more consistent and less-misleading naming over drawbacks for more changes when making necessary changes (code will require some amount of changes for 3.x even without any renaming).
Due to historical reasons, many entities have "Json" as a prefix or included in names. It would be good to remove these in cases where handling is format-agnostic, and leave it for truly JSON-specific handlers.
NOTE: for practical reasons, we will NOT change names of jackson-annotations
; there @JsonXxx
usage will continue.
- Retain "get"/"set" when needed by serialization (by Jackson itself)
- For example, location object (
TokenStreamLocation
)
- For example, location object (
- Object Values in token streams have "properties", not "fields" (not "entries" or "elements" or "values")
- Note: term "value" is also used in context of
JsonNode
for Array elements and value part of Object properties.
- Note: term "value" is also used in context of
- Array Values in token streams have "elements"
- POJOs (Java Value types), Beans, have "properties" as well
-
String
values should be accessed with accessors using term "String", not "Text" (like 2.x API does in places) - Core (streaming) concepts:
- "Token Streams" are used for reading and writing sequences of tokens (
JsonToken
)
- "Token Streams" are used for reading and writing sequences of tokens (
- Databind entities
- Value and Type Serializers/Deserializers are handlers that read from/write to Token Streams in order to convert Java Values to/from content like JSON
- "Object" has been overloaded: with 3.x refers to values in Token Streams (like "JSON Object Values") and their representations in Tree Model -- but NOT to any Java values (like
java.lang.Object
)- Java Values are referred to as POJOs at core (streaming level), and as "Beans" at Databind level
- NOTE: while we can and should use POJO (or sometimes, Bean) for Java Values, there is one specific set of entities we should NOT touch:
ObjectMapper
/ObjectReader
/ObjectWriter
-- see next section
- When adding Java 8 Stream support methods, singular naming is used. So,
JsonNode
for example has:-
values()
(returningCollection<JsonNode>
) -
valueStream()
(returningStream<JsonNode>
) valueSpliterator()
-
Since the vast majority of Jackson is through databinding -- and in particular using ObjectMapper
(or its light-weight relatives, ObjectReader
and ObjectWriter
) -- we should not rename these entities. This despite the fact that "Object" in this case is misleading, and ideally these should probably be called ValueMapper
/ ValueReader
/ ValueWriter
.
Another such use case is use of "Tree Model", and especially its base type JsonNode
. While reference to "Json" is misleading in this case -- it is used as general-purpose Tree Model regardless of underlying dataformat being read/written -- changing name of this type seems too intrusive for the user base.
But one user-visible change we will make is renaming of most exceptions (to remove Json
from names): this because as per JSTEP-4, changes to method signatures are needed anyway now that JacksonException
no longer extends IOException
.
Note that some changes to naming have been introduced earlier (methods added in 2.10 .. 2.19; older version removed from 3.0 branch as part of general "remove deprecated methods" work).
Renamed Entities (in com.fasterxml.jackson.core
unless otherwise stated):
-
JsonFactory
->TokenStreamFactory
(base class; there is actualJsonFactory
but now incom.fasterxml.jackson.core.json
) -
JsonStreamContext
->TokenStreamContext
core#411 -
JsonLocation
->TokenStreamLocation
core#1364
Renamed Exceptions (see JSTEP-4 for details)
-
JsonProcessingException
->JacksonException
(ultimate base exception) core#640-
JsonParseException
->StreamReadException
-
JsonEOFException
->UnexpectedEndOfInputException
core#663
-
-
JsonGenerationException
->StreamWriteException
-
Entity renaming work still being considered:
-
JsonEncoding
: May want to change, but there are questions about whether it'd be necessary to extend choice of encodings -
JsonParser
: might want to rename asTokenStreamReader
ORToken[Stream]Parser
- Related:
JsonParserDelegate
,FilteringParserDelegate
,JsonParserSequence
-- get renamed if main class does - Might also want to rename:
ParserBase
,ParserMinimalBase
(if Parser->Reader change made) - Ultimately might be too intrusive, considering NOT renaming
- Related:
-
JsonGenerator
: might want to rename asTokenStreamWriter
ORToken[Stream]Generator
- Related:
JsonGeneratorDelegate
,FilteringGeneratorDelegate
to be renamed if main class is - Might also want to rename:
GeneratorBase
(if Generator->Writer change made) - Ultimately might be too intrusive, considering NOT renaming
- Related:
No plans to rename:
-
JsonPointer
: named after JSON Pointer expressions, not content -
JsonToken
/JsonTokenId
: while it might make sense otherwise probably too intrusive at this point?- But note the somewhat intrusive change already made:
JsonToken.FIELD_NAME
->JsonToken.PROPERTY_NAME
- But note the somewhat intrusive change already made:
-
JsonpCharacterEscapes
: related to JSONP escaping, format-specific -
JsonStringEncoder
: specific to escaping of characters for JSON String values
Method/field name changes:
-
JsonGenerator
-
JsonParser
- replace references to "field" with "property" core#670
- replace
getCurrentLocation()
/getTokenLocation()
withcurrentLocation()
/currentTokenLocation()
core#671 - replace
getCurrentValue()
/setCurrentValue()
withcurrentValue()
/assignCurrentValue()
core#674 - replace "xxxTextYyy" methods (like
getTextCharacters()
) with "xxxStringYyy" methods (likegetStringCharacters()
) core#1378- NOTE: due to wide-spread usage, some methods (specifically
getText()
) will be left as deprecated, not removed, whereas less-commonly used methods will be just removed
- NOTE: due to wide-spread usage, some methods (specifically
-
JsonToken
:JsonToken.FIELD_NAME
->JsonToken.PROPERTY_NAME
core#670
Renamed Entities (in com.fasterxml.jackson.databind
unless otherwise stated):
-
Bean[De]SerializerModifier
/Value[De]SerializerModifier
#3047- Although parts are Bean-specific, also handles non-Bean serializers/deserializers
-
JsonSerializer
/JsonDeserializer
->ValueSerializer
/ValueDeserializer
#3044 -
JsonSerializable
->JacksonSerializable
? #3046- not JSON-specific; also seems good for just this case to outline it's Jackson-specific, due to typical usage
-
Module
->JacksonModule
#3037- one-off, due to conflict with
java.lang.Module
(added in Java 9)
- one-off, due to conflict with
-
TextNode
(in ``com.fasterxml.jackson.databind.node) ->
StringNode` databind#4879 (part of JSTEP-3
Renamed Exceptions (see JSTEP-4 for details)
No plans to rename:
-
ObjectMapper
/ObjectReader
/ObjectWriter
: while ambiguous wrt POJO/Bean, too intrusive for "regular" users -
JsonNode
(and related): similarly too intrusive -
JsonSchema
(and related visitors): specific to JSON Schema so valid -- although these types may get deprecated altogether -
BeanDeserializerBuilder
/BeanSerializerBuilder
: these are specific to Bean/POJO case and not just general value (de)serialization
-
AnnotationIntrospector
-
databind#4818: Rename
AnnotationIntrospector.findDefaultCreator()
asfindPreferredCreator()
-
databind#4818: Rename
-
JsonNode
: changes, including renaming, covered in separate JSTEP-3.