@JsonIgnore的源码说明
@JsonIgnore不仅仅是在getter上有影响,也对setter方法有影响:
所在包:com.fasterxml.jackson.annotation;
源码:
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; /**
* Marker annotation that indicates that the annotated method or field is to be//标记方法或字段
* ignored by introspection-based//被标记的方法和字段不进行序列化和反序列化
* serialization and deserialization functionality. That is, it should
* not be consider a "getter", "setter" or "creator".//实际上就是:这个注解不能被认为是一个getter,setter或creator
*<p>
* In addition, starting with Jackson 1.9, if this is the only annotation//1.9版本如果仅加入此注解,将会导致整个属性被忽视
* associated with a property, it will also cause the whole
* property to be ignored: that is, if setter has this annotation and//如果在setter上注解,在getter上不注解,那么getter也会受影响(将不会被序列化)
* getter has no annotations, getter is also effectively ignored.
* It is still possible for different accessors to use different//不同的存取器可以用不同的注解
* annotations; so if only "getter" is to be ignored, other accessors//如果仅是getter加了此注解,那么其他的存取器(setter或字段)
* (setter or field) would need explicit annotation to prevent//需要明确地被注解以防止不被序列化(通常使用@JsonProperty来注解)
* ignoral (usually {@link JsonProperty}).
* <p>
* For example, a "getter" method that would otherwise denote
* a property (like, say, "getValue" to suggest property "value")
* to serialize, would be ignored and no such property would
* be output unless another annotation defines alternative method to use.
*<p>
* Before version 1.9, this annotation worked purely on method-by-method (or field-by-field)
* basis; annotation on one method or field did not imply ignoring other methods
* or fields. However, with version 1.9 and above, annotations associated
* with various accessors (getter, setter, field, constructor parameter) of
* a logical property are combined; meaning that annotations in one (say, setter)
* can have effects on all of them (if getter or field has nothing indicating
* otherwise).
*<p>
* Annotation is usually used just a like a marker annotation, that
* is, without explicitly defining 'value' argument (which defaults
* to <code>true</code>): but argument can be explicitly defined.
* This can be done to override an existing JsonIgnore by explicitly
* defining one with 'false' argument.
*<p>
* Annotation is similar to {@link javax.xml.bind.annotation.XmlTransient}
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonIgnore
{
/**
* Optional argument that defines whether this annotation is active
* or not. The only use for value 'false' if for overriding purposes
* (which is not needed often); most likely it is needed for use
* with "mix-in annotations" (aka "annotation overrides").
* For most cases, however, default value of "true" is just fine
* and should be omitted.
*/
boolean value() default true;
}
JsonIgnore可以标注在字段、方法上(1.9版本及以上),当注解@JsonIgnore时,会发生两件事:
①:不会被jackson解析;
②:所修饰的字段或方法不参与序列化过程
@JsonIgnore的源码说明的更多相关文章
- json.net 比jsonIgnore 更好的方法 修改源码
关于 JsonIgnore 问题, EF T4 模板 中 存在主外键关系 namespace WindowsFormsApplication1{ using System; using ...
- 源码学习之ASP.NET MVC Application Using Entity Framework
源码学习的重要性,再一次让人信服. ASP.NET MVC Application Using Entity Framework Code First 做MVC已经有段时间了,但看了一些CodePle ...
- spark源码学习-withScope
withScope是最近的发现版中新增加的一个模块,它是用来做DAG可视化的(DAG visualization on SparkUI) 以前的sparkUI中只有stage的执行情况,也就是说我们 ...
- Springboot+Redisson自定义注解一次解决重复提交问题(含源码)
前言 项目中经常会出现重复提交的问题,而接口幂等性也一直以来是做任何项目都要关注的疑难点,网上可以查到非常多的方案,我归纳了几点如下: 1).数据库层面,对责任字段设置唯一索引,这是最直接有效 ...
- 【原】Android热更新开源项目Tinker源码解析系列之三:so热更新
本系列将从以下三个方面对Tinker进行源码解析: Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Android热更新开源项目Tinker源码解析系列之二:资源文件热更新 A ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 从源码看Azkaban作业流下发过程
上一篇零散地罗列了看源码时记录的一些类的信息,这篇完整介绍一个作业流在Azkaban中的执行过程,希望可以帮助刚刚接手Azkaban相关工作的开发.测试. 一.Azkaban简介 Azkaban作为开 ...
- 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新
[原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...
随机推荐
- Leetcode 23.Merge Two Sorted Lists Merge K Sorted Lists
Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list shoul ...
- Idea2018激活
[help]-->[register]-->[license server]-->输入下方链接 http://xdouble.cn:8888/ 如果不行,请用下面的这个: http: ...
- 也来说说C#异步委托 (转自 Rising_Sun)
前些日子,看到园子里面有人用老王喝茶的例子讲解了一下同步和异步,虽然没有代码实现,但是能够通俗易懂的讲解了同步.异步.阻塞.非阻塞的关系了,今天借题发挥,用一个热水器加热洗澡的例子来具体演示一下C#使 ...
- notepad++支持自定义文件类型
场景描述: 使用notepad++编辑less.ejs文件,发现高亮和提示均无效,修改如此需要进行额外的设置: 解决方法: 以less为例, 1.设置 >语言格式设置 >语言里找到CSS, ...
- ENUMSTXT.H中的指针数组
/************************************************************************ ...
- 学习笔记20151211——AXI4 STREAM DATA FIFO
AXI4 STREAM DATA FIFO是输入输出接口均为AXIS接口的数据缓存器,和其他fifo一样是先进先出形式.可以在跨时钟域的应用中用于数据缓冲,避免亚稳态出现.支持数据的分割和数据拼接.在 ...
- Git 学习之 Git Basics
最近在用git,但git学习曲线实在是有点高. 好在找到一个文档 https://www.atlassian.com/git/tutorial/,以下就是学习笔记吧! git init git ini ...
- eclipse加入c标签
在MyEclipse中使用jstl标签只需导读jstl.jar就能使用,但是在Eclipse中还需要一点小套路 步骤: 一.导入jstl.jar 二.导入导入standard.jar 三.在WEB-I ...
- 五种开源协议的比较(BSD,Apache,GPL,LGPL,MIT)
本篇博客比较了常见的5种开源协议的异同,大家在为自己的代码选择协议的时候可以参考.现今存在的开源协议很多,而经过Open Source Initiative组织通过批准的开源协议目前有58种(http ...
- 使用catch做单元测试简介
开始使用catch呢! catch的好处是,它只有一个头文件, 坏处是,它需要C++11,不过不是很坏. catch有两种测试用例的书写方式: Normal unsigned int Factoria ...