杰森避免反思 [英] Gson avoid reflection

查看:76
本文介绍了杰森避免反思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法避免在Gson中发生反思?我知道当您使用registerTypeAdapter时可以避免使用它,但是如果您在类成员上使用@SerializedName("name")注释,也可以避免使用id吗?

Is there a way to avoid reflection in Gson? I know that when you will use registerTypeAdapter you can avoid it, but if you use @SerializedName("name") annotation on class member, can you avoid id too?

推荐答案

您可以使用自动值自动值gson ,它将为您创建一个无反射适配器.

You can use Autovalue and Autovalue-gson that will create a reflection free adapter for you.

这篇关于杰森避免反思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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