Jackson注解 @get:JsonValue,对应的GSON注解相当于:

huangapple go评论75阅读模式
英文:

Jackson annotation @get:JsonValue, GSON equivalent

问题

有没有类似于Jackson的@get:JsonValue的GSON等效注释?

我有以下枚举,并且我需要GSON的注释。

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

Is there a GSON equivalent annotation for Jackson's @get:JsonValue?

I have the below enum and I need the GSON annotation as well.

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

答案1

得分: 1

这是:

enum class Type(@get:JsonValue val code: Int, val description: String) {
    @SerializedName("0") NEGATIVE(2, "负数金额"),
    @SerializedName("1") CREDIT(3, "信用。"),
    @SerializedName("2") WAGERS(6, "赌注"),
    @SerializedName("3") ZERO(8, "零。")
}

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

英文:

It was:

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.")
}

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

huangapple
  • 本文由 发表于 2020年10月7日 21:52:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/64245535.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定