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

QName (de)serialization ignores prefix #4771

Closed
1 task done
jpraet opened this issue Oct 30, 2024 · 1 comment · Fixed by #4968
Closed
1 task done

QName (de)serialization ignores prefix #4771

jpraet opened this issue Oct 30, 2024 · 1 comment · Fixed by #4968
Labels
2.19 Issues planned at 2.19 or later
Milestone

Comments

@jpraet
Copy link

jpraet commented Oct 30, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

QName (de)serialization ignores prefix, because it uses QName#toString() and QName#valueOf(java.lang.String).

Version Information

2.17.2

Reproduction

        QName qname = new QName("http://test.com", "test", "p");
        System.out.println(qname.getPrefix()); // <- p
        ObjectMapper mapper = new ObjectMapper();
        String ser = mapper.writeValueAsString(writer, qname);
        System.out.println(ser); // <- "{http://test.com}test"
        QName result = mapper.readValue(ser, QName.class);
        System.out.println(result.getPrefix()); // <- empty string

Expected behavior

QName prefix is preserved.

Additional context

No response

@cowtowncoder
Copy link
Member

Thank you for reporting this @jpraet.

I can see the problem, but it'll probably be difficult to resolve in a backwards-compatible way.

PRs welcome.

@cowtowncoder cowtowncoder added pr-welcome Issue for which progress most likely if someone submits a Pull Request and removed to-evaluate Issue that has been received but not yet evaluated labels Oct 30, 2024
mcvayc pushed a commit to mcvayc/jackson-databind that referenced this issue Jan 2, 2025
This commit fixes FasterXML#4771 by adding serialization and deserialization features to control whether a QName is serialized to a string using the "QName.toString()" method (the only option currently) or if it is serialized to JSON object (a new option to fix FasterXML#4771).
mcvayc pushed a commit to mcvayc/jackson-databind that referenced this issue Jan 15, 2025
This commit fixes FasterXML#4771 by adding serialization and deserialization features to control whether a QName is serialized to a string using the "QName.toString()" method (the only option currently) or if it is serialized to JSON object (a new option to fix FasterXML#4771).
mcvayc added a commit to mcvayc/jackson-databind that referenced this issue Feb 12, 2025
This commit fixes FasterXML#4771 by supporting the JsonFormat OBJECT shape during serialization and deserialization.
mcvayc added a commit to mcvayc/jackson-databind that referenced this issue Feb 14, 2025
This commit fixes FasterXML#4771 by supporting the JsonFormat OBJECT shape during serialization and deserialization.
@cowtowncoder cowtowncoder changed the title QName (de)serialization ignores prefix QName (de)serialization ignores prefix Feb 14, 2025
@cowtowncoder cowtowncoder added 2.19 Issues planned at 2.19 or later and removed pr-welcome Issue for which progress most likely if someone submits a Pull Request labels Feb 14, 2025
@cowtowncoder cowtowncoder modified the milestones: 2.1.7, 2.19.0 Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.19 Issues planned at 2.19 or later
Projects
None yet
2 participants