Skip to content

Commit

Permalink
Merge branch '2.15' into 2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 4, 2023
2 parents 26466cb + f678140 commit 23603ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ No changes since 2.15
#3913: Issue with deserialization when there are unexpected properties (due
to null `StreamReadConstraints`)
(reported by @sbertault)
#3914: Fix TypeId serialization for `JsonTypeInfo.Id.DEDUCTION`, native type ids

2.15.0 (23-Apr-2023)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.WritableTypeId;
import com.fasterxml.jackson.databind.BeanProperty;

Expand Down Expand Up @@ -39,9 +40,19 @@ public WritableTypeId writeTypePrefix(JsonGenerator g,
// write surrounding Object or Array start/end markers. But
// we are not to generate type id to write (compared to base class)

if (idMetadata.valueShape.isStructStart()
// also: do not try to write native type id
&& !g.canWriteTypeId()) {
if (idMetadata.valueShape.isStructStart()) {
// 03-May-2023, tatu: [databind#3914]: should not write Native Type Id;
// but may need to write the value start marker
if (g.canWriteTypeId()) {
idMetadata.wrapperWritten = false;
if (idMetadata.valueShape == JsonToken.START_OBJECT) {
g.writeStartObject(idMetadata.forValue);
} else if (idMetadata.valueShape == JsonToken.START_ARRAY) {
g.writeStartArray(idMetadata.forValue);
}
return idMetadata;
}
// But for non-wrapper types can just use the default handling
return g.writeTypePrefix(idMetadata);
}
return null;
Expand Down

0 comments on commit 23603ea

Please sign in to comment.