@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 ...
随机推荐
- Homebrew/Linuxbrew 安装常有工具
Homebrew https://brew.sh/ Install: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent ...
- python 字符串、列表、字典相关内建方法
"""字符串相关内建方法""" # a = ["qwe", "name", "sex&qu ...
- 本地Run Page时报检测到意外的 URL 参数,它将被忽略。
经查,是因为我RUN的时候 Target URL -- http://MY-PC:8988/OA_HTML/runregion.jsp 将MY-PC更改为本地IP即可. 设置方法 Tools - Em ...
- poj1191 棋盘分割。 dp
连接:http://poj.org/problem?id=1191 思路:额,其实就是直接搞记录一下就可以了. #include <stdio.h> #include <string ...
- Swagger使用总结(十九)
1. Swagger是什么? Swagger 是一款RESTFUL接口的文档在线自动生成+功能测试功能软件. 官方说法:Swagger是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTfu ...
- 041——VUE中组件之pros数据的多种验证机制实例详解
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 最短路之SPFA算法
部分来自:http://blog.csdn.net/juststeps/article/details/8772755 求最短路径的算法有许多种,除了排序外,恐怕是OI界中解决同一类问题算法最多的了. ...
- ActiveX开发
转自(http://blog.csdn.net/mingojiang/article/details/8159263) 一.ActiveX基础 1.1什么是ActiveX ActiveX是COM规范的 ...
- node 使用范围 和 node的优势 (为什么 创业公司 选择的不是 java php ruby 等)
链接 一些国外大公司 范围: 第一: 希望合并后台多个接口 成为一个接口, 或者频繁改动接口 相关, 比如数据 和数据格式之类, 后台难以配合, 这里可以使用node作为后台的应用层调用其他接口 ...
- Centos7 安装JDK环境和Tomcat
Linux JDK 64位下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.ht ...