micronaut-projects / micronaut-projects/micronaut-serialization
@JsonValue ignored by micronaut-serde
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 36
- Forks
- 29
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 29
Description
Expected Behavior
JSON body after serialization:
{"courier":"ups-mi"}
Actual Behaviour
JSON body after serialization:
{"courier":"UPS_MAIL_INNOVATION"}
Steps To Reproduce
- Use
com.fasterxml.jackson.annotation.JsonValueannotation in enum.
For example:
public enum Courier {
UPS("ups"),
USPS("usps"),
UPS_MAIL_INNOVATION("ups-mi"),
ASENDIA("asendia-usa"),
DHL("dhl-gm");
private final String code;
Courier(String code) {
this.code = code;
}
@JsonValue
public String getCode() {
return code;
}
}
- After serialization I have next JSON:
{"courier":"UPS_MAIL_INNOVATION"}
- But I should have:
{"courier":"ups-mi"}
You can find example with serde here.
Example with jackson (works correct) here.
Environment Information
Mac OS Sonoma 14.3.1
JDK 21
Example Application
https://github.com/alexey-plotnikoff/micronaut-serde
Version
4.3.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked micronaut-serde example application and reproduce enum serialization using com.fasterxml.jackson.annotation.JsonValue. Compare its output with the linked micronaut-jackson example, then trace the enum serialization entry point. Done means the Courier value serializes as its code, such as "ups-mi", rather than the enum constant name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100