@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的源码说明的更多相关文章

  1. json.net 比jsonIgnore 更好的方法 修改源码

    关于 JsonIgnore  问题, EF T4 模板 中 存在主外键关系 namespace WindowsFormsApplication1{    using System;    using ...

  2. 源码学习之ASP.NET MVC Application Using Entity Framework

    源码学习的重要性,再一次让人信服. ASP.NET MVC Application Using Entity Framework Code First 做MVC已经有段时间了,但看了一些CodePle ...

  3. spark源码学习-withScope

     withScope是最近的发现版中新增加的一个模块,它是用来做DAG可视化的(DAG visualization on SparkUI) 以前的sparkUI中只有stage的执行情况,也就是说我们 ...

  4. Springboot+Redisson自定义注解一次解决重复提交问题(含源码)

    前言   项目中经常会出现重复提交的问题,而接口幂等性也一直以来是做任何项目都要关注的疑难点,网上可以查到非常多的方案,我归纳了几点如下:   1).数据库层面,对责任字段设置唯一索引,这是最直接有效 ...

  5. 【原】Android热更新开源项目Tinker源码解析系列之三:so热更新

    本系列将从以下三个方面对Tinker进行源码解析: Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Android热更新开源项目Tinker源码解析系列之二:资源文件热更新 A ...

  6. C# ini文件操作【源码下载】

    介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...

  7. 【原】FMDB源码阅读(三)

    [原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...

  8. 从源码看Azkaban作业流下发过程

    上一篇零散地罗列了看源码时记录的一些类的信息,这篇完整介绍一个作业流在Azkaban中的执行过程,希望可以帮助刚刚接手Azkaban相关工作的开发.测试. 一.Azkaban简介 Azkaban作为开 ...

  9. 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新

    [原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...

随机推荐

  1. C# 字符串与字节数组相互转换

    https://www.cnblogs.com/xiaoqingshe/p/5882601.html

  2. 【Demo】CSS3 动画 加载进度条

    实例结果图: 完整代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  3. jquery性能优化的十种方法

    jquery性能优化的十种方法 有时候我们在书写jquery的时候,为了书写代码方便,往往忽略了程序执行过程中,给客户端带来的压力.随之而来的就是在某些低端浏览器或者低端电脑上运行速度缓慢,甚至无法运 ...

  4. UVA-11183 Teen Girl Squad (最小树形图、朱刘算法模板)

    题目大意:给一张无向图,求出最小树形图. 题目分析:套朱-刘算法模板就行了... 代码如下: # include<iostream> # include<cstdio> # i ...

  5. c++ 中的 set

    set (集合) 中的元素是排序好的,而且是不重复的. 例题:hdu 4989 题目大意:求一组数列中任意两个不重复元素和,再求不重复和的和. #include <bits/stdc++.h&g ...

  6. 004——php字符串中处理函数(三)

    <?php /** * 字符串替换函数: * str_replace(); 替换字符串或数组元素,区分大小写,第四个参数可选,用于统计替换次数 * str_ireplace()不区分大小写替换 ...

  7. js获取当前日期加上30天之后的日期

    var date1 = new Date(); var date2 = new Date(date1); date2.setDate(date1.getDate() + 30); console.lo ...

  8. windows下编译Hugin时的template错误

    Hugin依赖于VIGRA,而VIGRA包含大量的模板,编译Hugin是出现如下的大量错误: "unexpected token(s) preceding ':'; skipping app ...

  9. Leetcode 1021. Remove Outermost Parentheses

    括号匹配想到用栈来做: class Solution: def removeOuterParentheses(self, S: str) -> str: size=len(S) if size= ...

  10. Java第二次作业--数组和String类

    Deadline: 2017-3-28 23:00 一.学习要点 认真看书并查阅相关资料,掌握以下内容: 掌握基本数据类型和引用数据类型的区别 理解对象的生成与引用的关系 掌握构造方法的重载 掌握St ...