Skip to content

Apply JsonTypeInfo.Value usages from Jackson 3.0 #3953 #600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added jackson-databind-2.16.0-SNAPSHOT-8.jar
Binary file not shown.
17 changes: 12 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos.
<!-- Extends Jackson (jackson-mapper); requires Stax API (and implementation on
deploy time), Stax2 API.
-->
<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not need to do this, as long as jackson-base version 2.16.0-SNAPSHOT has dependencies to 2.16.0-SNAPSHOT. You can also re-build snapshot locally for jackson-databind (with ./mvnw clean install) and that version should be used without other workarouns.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, it works without this <dependency> prop, thanksss 🥹

<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>system</scope>
<systemPath>${project.basedir}/jackson-databind-2.16.0-SNAPSHOT-8.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand All @@ -49,11 +55,12 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos.
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>


<!-- <dependency>-->
<!-- <groupId>com.fasterxml.jackson.core</groupId>-->
<!-- <artifactId>jackson-databind</artifactId>-->
<!-- </dependency>-->

<!-- 20-Mar-2019, tatu: Stax-api been part of JDK since Java 6, so let's drop
dependency as it causes issues with JDK9+ module info
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.PropertyName;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.*;
import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.dataformat.xml.annotation.*;
Expand Down Expand Up @@ -225,6 +228,11 @@ protected StdTypeResolverBuilder _constructStdTypeResolverBuilder() {
return new XmlTypeResolverBuilder();
}

@Override
protected TypeResolverBuilder<?> _constructStdTypeResolverBuilder(MapperConfig<?> config, JsonTypeInfo.Value typeInfo, JavaType baseType) {
return new XmlTypeResolverBuilder(typeInfo);
}

/*
/**********************************************************************
/* Internal methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
*/
public class XmlTypeResolverBuilder extends StdTypeResolverBuilder
{
public XmlTypeResolverBuilder() {
}

public XmlTypeResolverBuilder(JsonTypeInfo.Value settings) {
super(settings);
}

@Override
public StdTypeResolverBuilder init(JsonTypeInfo.Id idType, TypeIdResolver idRes)
{
Expand All @@ -35,6 +42,15 @@ public StdTypeResolverBuilder init(JsonTypeInfo.Id idType, TypeIdResolver idRes)
return this;
}

@Override
public StdTypeResolverBuilder init(JsonTypeInfo.Value settings, TypeIdResolver idRes) {
super.init(settings, idRes);
if (_typeProperty != null) {
_typeProperty = StaxUtil.sanitizeXmlTypeName(_typeProperty);
}
return this;
}

@Override
public StdTypeResolverBuilder typeProperty(String typeIdPropName)
{
Expand Down