从java瞬态或@Transient注释隐藏JSON序列化属性的最佳方法? [英] Best method in hiding attribute in JSON serialization from java transient or @Transient annotation?

查看:70
本文介绍了从java瞬态或@Transient注释隐藏JSON序列化属性的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Spring,ExtJs 应用程序中,我使用 Java 对象的 JSON 序列化.当我想从 JSON 中排除一个属性时,我使用 @Transient 注释.

In Spring, ExtJs application I use JSON serialization of java objects. When I want to exclude a property from JSON, I use @Transient annotation.

我看到 java transient 关键字也适用于此.我想知道哪些在性能方面和安全性方面最好且更高效.

I see java transient keyword also works with this. I like to know which of these are best and more efficient in performance perspective and security.

推荐答案

我更喜欢使用基于注解的映射.因为这可能取决于您的 JSON 解析器 API.因此,java annotation@Transient 之间可能存在差异.

I prefer to use annotation based mapping. Because this may dependent on you JSON parser API. So, there can be variations between java annotation Vs @Transient.

这篇关于从java瞬态或@Transient注释隐藏JSON序列化属性的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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