-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Jackson Release 2.7
Version 2.7 development started in August 2015; and the first official release happened on January 10, 2016.
- New datatype module: jackson-datatype-pcollections
- Kotlin module become official with 2.7.2, as that is the first version based on the official Kotlin 1.0
Beyond initial 2.7.0 (described here), following patch releases have been made or are planned:
- 2.7.1 (02-Feb-2016)
- 2.7.2 (27-Feb-2016)
- 2.7.3 (16-Mar-2016)
- 2.7.4 (29-Apr-2016)
- 2.7.5 (11-Jun-2016)
- 2.7.6 (not yet released)
Starting with 2.7, JDK baseline will be Java 7 / JDK 7, with following exceptions:
-
jackson-annotations
andjackson-core
(streaming) will remain Java 6 - No new language features are yet used (diamond pattern, try-with-resources); only JDK types
- All JDK 7 types are accessed dynamically
- Deserializer for
java.nio.file.Path
- Handling of new annotations under
java.beans
:@ConstructorProperties
,@Transient
viaJacksonAnnotationIntrospector
, but
- Deserializer for
So it should still be possible to use Jackson 2.7 on Java 6, but not compile, build.
With Jackson 2.8, Java 7 languages features will be allowed
With Jackson 2.6, ObjectReader
allows passing of JsonParser.Feature
overrides, and ObjectWriter
similarly JsonGenerator.Feature
overrides. But there are some format-specific features for formats like CSV
which were not being passed before 2.7.
Since ObjectReader
and ObjectWriter
are not easy to sub-class (an attempt to do so pointed out a few inconvenient quirks Java typing would impose), it would be most convenient to be able to pass opaque bitflags to actual parser/generator implementation, and this is what has been added.
While Jackson has the best support for generic types of all Java JSON libraries, there are certain tricky edge cases that do not work. Specifically, type variable aliasing (case where variable name like T
binds to different types at different points in hierarchy) is not correctly resolved, as variable binding is constructed globally and not hierarchically.
java-classmate
library which was built based on my experiences with Jackson does handle all these cases correctly (to my knowledge), and could be used as a blueprint for improved system. It can not necessarily be used directly because Jackson's type system is more complicated and adds semantics that classmate does not use (like Map
and Collection
types being special), but should help as an example.
Although the intent has always been that Include.NON_EMPTY
would apply not just to empty arrays, Collection
s , Map
s and String
s, to include things like numbers with default values (0
for int
, for example). But since many JsonSerializer
s did NOT properly check for these conditions, before Jackson 2.6 NON_EMPTY
exclusion did not work as extensively as intended, and many users came to depend on this specific behavior.
With 2.6 serializers were improved to handle "emptiness" as originally envisioned. This confused some of users, leading to confusion and frustration on what seemed like arbitrary changes.
After lengthy discussions over this issue, it seems that instead of using extended definition of what is empty, it makes more sense to use another value, NON_DEFAULT
for such concept, and keep NON_EMPTY
to strictly ONLY exclude:
- Anything that is
null
(that is, a superset ofNON_NULL
) - Anything that is "absent" (for
Optional
s and other "Reference Types" -- superset ofNON_ABSENT
) - Empty container types with no elements:
java.util.Collection
java.util.Map
- Java arrays
- Empty Strings
With that, NON_DEFAULT
will have two modes:
- When applied on containing class, it will try to compare actual defaults values of the POJO for given properties
- Otherwise (when
NON_DEFAULT
is either default global or per-type value; or used as per-property override), use per-type criteria, where:- anything that would be considered "empty" is excluded, but also
- default values for primitives (like
0
forint
) and their wrappers (Integer.valueOf(0)
forInteger
) are also excluded
-
#37: Add
@JsonClassDescription
-
#77: Add a new
ObjectIdGenerator
,StringIdGenerator
, to allow arbitraryString
Object Id usage - Major rewrite of merging of
JsonFormat.Value
andJsonInclude.Value
, to allow for better multi-level defaults (global, per-type, property)
-
#37:
JsonParser.getTokenLocation()
doesn't update after field names -
#198: Add back-references to
JsonParser
/JsonGenerator
for low-level parsing issues (viaJsonParseException
,JsonGenerationException
) -
#211: Fix typo of function name
com.fasterxml.jackson.core.Version.isUknownVersion()
(addisUnknownVersion()
, deprecated misspelled variant) - #229: Array element and field token spans include previous comma.
- 76: Problem handling datatypes Recursive type parameters
-
819: Add support for setting
FormatFeature
viaObjectReader
,ObjectWriter
-
905: Add support for
@ConstructorProperties
-
909: Rename PropertyNamingStrategy
CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES
asSNAKE_CASE
,PASCAL_CASE_TO_CAMEL_CASE
asUPPER_CAMEL_CASE
-
918: Add
MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING
- 948: Support leap seconds, any number of millisecond digits for ISO-8601 Dates.
-
952: Revert non-empty handling of primitive numbers wrt
NON_EMPTY
; makeNON_DEFAULT
use extended criteria -
957: Merge
datatype-jdk7
stuff in (java.nio.file.Path handling) - 959: Schema generation: consider active view, discard non-included properties
-
963: Add PropertyNameStrategy
KEBAB_CASE
-
997: Add
MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS
-
998: Allow use of
NON_DEFAULT
for POJOs without default constructor - 1000: Add new mapping exception type for enums and UUIDs
- 1010: Support for array delegator
-
1044: Add
AnnotationIntrospector.resolveSetterConflict(...)
to allow custom setter conflict resolution
-
#21: Add
AVRO_BUFFERING
feature forAvroParser
,AvroGenerator
(enabled by default, same as existing pre-2.7 behavior)
-
#81: Add alternative way to configure 'wrap-as-array', as
CsvParser
feature -
#89: Allow choice of using header-line declaration to reorder columns of explicit schema, with
CsvSchema.setReorderColumns
- #92: Allow multi-character separator values
-
#94: Change schema/mapping related
JsonParseException
s to properJsonMappingException
s -
#95: Add
CsvParser.Feature.IGNORE_TRAILING_UNMAPPABLE
to allow skipping of all extra, unmappable columns -
#97: Verify CSV headers are in the order as expected (added
strictHeaders
property inCsvSchema
) -
#103:
JsonGenerator.Feature.IGNORE_UNKNOWN
does not prevent error when writing structured values - #106: Null fields are always ignored when serializing list of
-
#109: Allow specifying (via
CsvSchema
) a way to map "extra" columns into specific key (to use via any setter)
- #11: dd Support for Generating Protobuf Schema From POJO Definition
-
#156: Add
XmlMapper.setDefaultUseWrapper()
for convenience. - #167: Exception on deserializing empty element with an xsi attribute
- #169: Fail to deserialize "empty" polymorphic classes
- #180: Problem with deserialization of nested non-wrapped lists, with empty inner list
- 38: Add MINIMIZE_QUOTES generator feature
- 50: Lack of SnakeYAML Resolver leaves some missing features
- #79: New configuration for Guava Range default bound type.
-
#54:
LocalDateTimeSerializer
default constructor should use the same formatter asLocalDateTimeDeserializer
-
#52: Add a feature in
JaxbAnnotationIntrospector
to define meaning ofnillable=false
as "JsonInclude.NON_EMPTY"