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

@JsonValue ignored by micronaut-serde #780

Open
alexey-plotnikoff opened this issue Feb 29, 2024 · 1 comment
Open

@JsonValue ignored by micronaut-serde #780

alexey-plotnikoff opened this issue Feb 29, 2024 · 1 comment
Labels
type: improvement A minor improvement to an existing feature

Comments

@alexey-plotnikoff
Copy link

Expected Behavior

JSON body after serialization:

{"courier":"ups-mi"}

Actual Behaviour

JSON body after serialization:

{"courier":"UPS_MAIL_INNOVATION"}

Steps To Reproduce

  1. Use com.fasterxml.jackson.annotation.JsonValue annotation 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;
    }
}
  1. After serialization I have next JSON:
{"courier":"UPS_MAIL_INNOVATION"}
  1. 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

@yawkat yawkat added the type: improvement A minor improvement to an existing feature label Mar 7, 2024
@dstepanov
Copy link
Contributor

Enum needs to be annotated with @Serdeable. Maybe we can make it @Serdeable by default in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants