Gson是否有类似@JsonProperty的方法? [英] Does Gson have something like @JsonProperty for methods?

查看:1009
本文介绍了Gson是否有类似@JsonProperty的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jackson具有@JsonProperty("name")批注,该批注可以应用于方法-该方法的返回值将分配给JSON中的"name"参数.

Jackson has the @JsonProperty("name") annotation, which can be applied to methods - the return value of the method will be assigned to the "name" parameter in the JSON.

我发现Gson具有@SerializedName批注,但是不能与方法一起使用.有什么方法可以为Gson中的方法获取@JsonProperty功能吗?

I found out that Gson has the @SerializedName annotation, but that cannot be used with methods. Is there any way to get the @JsonProperty functionality for methods in Gson?

推荐答案

尝试

@SerializedName("serialized_fld_name")

@SerializedName("serialized_fld_name")

这篇关于Gson是否有类似@JsonProperty的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆