@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 ...
随机推荐
- Curious Array CodeForces - 407C (高阶差分)
高阶差分板子题 const int N = 1e5+111; int a[N], n, m, k; int C[N][111], d[N][111]; signed main() { scanf(&q ...
- supervisor进程管理工具
Supervisor 一个python写的进程管理工具,用来启动.关闭.重启进程,可以同时控制多个进程. 安装: pip install supervisor 配置: 通过配置文件来满足自己的需求 配 ...
- 过滤器系列(二)—— Cuckoo filter
这一篇讲的是布谷过滤器(cuckoo fliter),这个名字来源于更早发表的布谷散列(cuckoo hash),尽管我也不知道为什么当初要给这种散列表起个鸟名=_= 由于布谷过滤器本身的思想就源自于 ...
- MySQL重装
一.在控制面板中卸载程序 二.找到安装目录,删除掉剩余的文件,一般在C:\Program Files\MySQL\和C:\ProgramData\MySQL\ 三.清理注册表,在“运行”里键入rege ...
- MarkdownPad2 下一些设置
MarkdownPad2注册码: 邮箱: Soar360@live.com 授权秘钥: GBPduHjWfJU1mZqcPM3BikjYKF6xKhlKIys3i1MU2eJHqWGImDHzWdD6 ...
- xtrabackup备份之增量备份(二)
测试了差不多一周的xtrabackup,本篇主要聊一下xtrabackup的增量备份.我一开始不是很了解,为什么每周都需要做全备份,每天都需要做增量备份,现在想想这个和技术无关.但是有一个新问题,如果 ...
- javascript---关于字符串和数组的方法
在学习javascript过程中,遇到过很多关于数组和字符串的一些操作.之前也总结了不少方法,可是一遇到自己用的时候,就忘了.不是忘了方法叫什么名,就是忘了方法的参数有什么,返回的是什么? 现在就再次 ...
- form表单post请求保护 隐藏秘钥
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [例1.10]使用setw设置输出宽度的例子
[例1.10]使用setw设置输出宽度的例子: #include <iostream> #include <iomanip> using namespace std; void ...
- 我的octopress配置
在github上用octopress搭建了自己的blog,octopress号称是"专门给黑客打造的博客(A blogging framework for 把hackers)",使 ...