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

feat: Fix the issue where the JsonValue annotation cannot be used on an enum. #910

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

shalousun
Copy link
Collaborator

@shalousun shalousun commented Sep 5, 2024

public enum TrainJobType {
    TRAIN_TENSORFLOW_JOB( "train-tensorflow-job"),
    TRAIN_PYTORCH_JOB("train-pytorch-job");

    private final String value;

    TrainJobType(String value) {
        this.value = value;
    }
    @JsonValue
    public String getValue() {
        return value;
    }
}

  • The @JsonValue annotation is applied to the getValue() method. This means that when an instance of TrainJobType is serialized to JSON, the value returned by getValue() is used.

  • For example, if you serialize TrainJobType.TRAIN_TENSORFLOW_JOB, the resulting JSON would be train-tensorflow-job.

@shalousun shalousun added the bug Something isn't working label Sep 5, 2024
@shalousun shalousun added this to the 3.0.8 milestone Sep 5, 2024
@shalousun shalousun merged commit 1e1ef98 into TongchengOpenSource:master Sep 5, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant