杰克逊注释@get:JsonValue,相当于GSON

时间:2020-10-07 13:52:32

标签: java json spring jackson gson

Jackson的@get:JsonValue是否有GSON等效注解?

我有下面的枚举,我也需要GSON注释。

enum class TransactionType(@get:JsonValue val code: Int) { ... }

1 个答案:

答案 0 :(得分:0)

是:

enum class Type(@get:JsonValue val code: Int, val description: String) {
    @SerializedName("0") NEGATIVE(2, "negative amount "),
    @SerializedName("1") CREDIT(3,"Credit."),
    @SerializedName("2") WAGERS(6,"wager"),
    @SerializedName("3") ZERO(8, "zero.")
}

参考: https://javadoc.io/doc/com.google.code.gson/gson/2.8.1/com/google/gson/annotations/package-summary.html