Skip to content
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

Unable to parse fields having a "@" prefix inside @JsonProperty value after upgrading jackson jars to 2.17.0 #721

Open
zenith7781 opened this issue Feb 17, 2025 · 4 comments

Comments

@zenith7781
Copy link

zenith7781 commented Feb 17, 2025

Hello, I am writing this after searching in the issues but couldn't get the required information.
I am using a spring boot project and I have a job where we feed an XML as input and the application processes it and returns the output. I have upgraded Spring boot to 3.3.7 which has automatically upgraded jackson jars to 2.17.3. However post this upgradation, I am facing an issue where jackson is not able to map/serialize the fields correctly. The mapping is defined as ::

@SuppressWarnings("javadoc")
@XmlAccessorType(XmlAccessType.FIELD)
@JsonPropertyOrder({"tc", "$"})
public class CodeCommandType implements Serializable {
  private static final long serialVersionUID = 1L;
  @XmlAttribute
  @JsonProperty("@tc")
  public int tc;
 @XmlValue
  public String $;
}

Sample XML Input:

<ns:RequestBasis id="RequestBasis_1">
        <ns:BasisName>Best of Current and State Non-Forfeiture</ns:BasisName>
        <ns:InterestAssumption tc="2">Current</ns:InterestAssumption>
        <ns:GtdPayoutAmt>194.24</ns:GtdPayoutAmt>
</ns:RequestBasis>

The error is thrown as "Unrecognized field "tc" (class org.rest.of.the.package.CodeCommandType), not marked as ignorable (2 known properties: "", "@tc"]) at [Source: (StringReader); line: 7, column: 27] "

Note that this issue gets resolved if I forcefully keep jackson to 2.16.2 OR put @JsonProperty("tc") instead of @JsonProperty("@tc").

I want to know the commit/issue/changelog or any related information where this configuration was updated inside 2.17.0 release. @cowtowncoder @JooHyukKim Any help will be appreciated.

@pjfanning pjfanning transferred this issue from FasterXML/jackson-databind Feb 17, 2025
@pjfanning
Copy link
Member

pjfanning commented Feb 17, 2025

jackson-dataformat-xml is where the XML support is - not jackson-databind.

Release Notes:
https://github.com/FasterXML/jackson-dataformat-xml/blob/2.19/release-notes/VERSION-2.x

Just in case, this issue relates to a jackson-databind change, its release notes are in:
https://github.com/FasterXML/jackson-databind/blob/2.19/release-notes/VERSION-2.x

@pjfanning
Copy link
Member

@zenith7781 I can't find any tests that have @JsonProperty("@x") or similar settings. I may have missed something but is possible that @ values in property names was only supported by accident.

@cowtowncoder
Copy link
Member

cowtowncoder commented Feb 17, 2025 via email

@cowtowncoder
Copy link
Member

Also: aside from Spring side, I would recommend trying out yet newer version, 2.18.2 -- 2.18 has a few fixes to Creator detection and handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants