Features for configuring JSON-to-Java mapping-程序员宅基地

技术标签: java  json  runtime  

Following on/off features are defined in DeserializationConfig.Feature (Jackson 1.x) or DeserializationFeature (Jackson 2.x):

 

ACCEPT_EMPTY_STRING_AS_NULL_OBJECT (default: false) (since 1.8)

Determines whether empty JSON String value is accepted as null value for regular POJOs ("beans") with data-binding: this can be useful when dealing endpoints written in a language that has loose typing and may represent missing objects as Empty Strings.

 

ACCEPT_SINGLE_VALUE_AS_ARRAY

Allows auto-conversion from non-JSON-array values to single-element arrays and Collections (adding implicit "array wrapper"): this is sometimes necessary for interoperability, as some libraries and frameworks omit JSON arrays when serializing single-element arrays.

 

AUTO_DETECT_CREATORS (default: true)

Controls whether potential creator methods (public single-argument constructors, public static methods that return instance of class itself (aka factory methods)) can be automatically detected without being annotated with @JsonCreator (or similar for alternate annotation introspector).

 

AUTO_DETECT_FIELDS (default: true)

Similar to AUTO_DETECT_SETTERS, controls whether public instance fields are recognized as deserializable properties.

 

AUTO_DETECT_SETTERS (default: true)

Controls whether "setter" methods are automatically detected (as opposed to located by annotations); if enabled, non-private single-argument non-static methods are recognized as setters (method used to set value of the logical property). If disabled, only ones explicitly annotated (using @JsonProperty, for example) are recognized as deserializable properties

 

CAN_OVERRIDE_ACCESS_MODIFIERS (default: true)

Whether non-public fields and methods can be forced accessible (using JDK provided methods or not): if disabled, non-public fields and methods can not be used for properties.

The main reason to disable this feature is if running on a security-restricted platform where trying to change access rights results in a runtime error.

 

FAIL_ON_INVALID_SUBTYPE (default: true) (since 2.2)

Determines what happens when type information for polymorphic types (see @JsonTypeInfo) is either missing or invalid (unmappable); if enabled, exception is thrown; if disabled, null reference is used instead (as type can not be determined).

 

FAIL_ON_NULL_FOR_PRIMITIVES (default: false) (since 1.7)

Determines whether JSON null is acceptable for Java primitive types (intbooleandouble etc); if set to 'false', default value is used; if 'true', a JsonProcessingException will be thrown.

 

FAIL_ON_NUMBERS_FOR_ENUMS (default: false) (since 1.7)

Determines whether JSON integer numbers (0, 1, 2, ...) can be deserialized into Java Enum types; if set to 'false', this is legal and value is used to deserialize value that matches Enum.ordinal(); if 'true', trying to deserialize JSON number into Enum throws a JsonProcessingException

 

FAIL_ON_UNKNOWN_PROPERTIES (default: true) (since 1.2)

Used to control whether encountering of unknown properties (one for which there is no setter; and there is no fallback "any setter" method defined using @JsonAnySetter annotation) should result in a JsonMappingException (when enabled), or just quietly ignored (when disabled)

 

READ_ENUMS_USING_TO_STRING (default: false) (since 1.6)

Determines which method is used to determine expected serialization of an Enum: if false (default), use Enum.name(); if true, Enum.toString().

 

USE_ANNOTATIONS (default: true) (since 1.2)

Controls whether any annotation introspection is used for configuring data binding: if disabled, all annotations are ignored (independent of setting for AnnotationIntrospector in use)

note: since 1.8, disable this feature will try to remove ALL annotation processing; this to help on platforms like Android, where trying to access unavailable annotation types (JAXB annotations for value types) can result in exception, even if not specifically looking for that annotation type.

 

USE_BIG_DECIMAL_FOR_FLOATS (default: false)

Controls whether java.math.BigDecimal is used for deserializing JSON floating point numbers, when resulting type is a generic type (java.lang.Object) or generic number type (java.lang.Number); if disabled type will be java.lang.Double

Does not affect explicit type (i.e. if expected result type is java.lang.Double or such)

 

USE_BIG_INTEGER_FOR_INTS (default: false)

Similar to USE_BIG_DECIMAL_FOR_FLOATS, but used when value to map is a JSON integer number (numeric value without decimal point). If enabled, type java.math.BigInteger is used for binding to generic types; if disabled, java.lang.Integer or java.lang.Long is used (smallest applicable type that can contain actual value)

 

USE_GETTERS_AS_SETTERS (default: true)

Controls whether "getters" that return Collection or Map types can be used for "setting" values (same as how JAXB API works with XML), so that separate "setter" method is not needed.

Even if enabled, explicit "setter" method will have precedence over implicit getter-as-setter, if one exists.

 

USE_JAVA_ARRAY_FOR_JSON_ARRAY (default: false) (since 1.9)

Determines whether to bind JSON Arrays as java.util.Lists or Object[] instances, when binding to nominal type of java.lang.Object: if disabled, as List, if enabled as Object[].

 

转载于:https://www.cnblogs.com/huey/p/5626974.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30721077/article/details/98047919

智能推荐

计算机中丢失msvcr100.dll怎么办,会声会影计算机中丢失MSVCR100.dll解决方案-计算机中丢失MSVCR100.dll怎么解决_好特教程...-程序员宅基地

文章浏览阅读632次。很多网友反映在会声会影官网下载会声会影x9试用版之后,打开时会出现报错,提示“无法启动此程序,因为计算机中丢失MSVCR100.dll。尝试重新安装改程序以解决此问题。”遇到这种情况该如何介解决呢?图一:系统错误打开提示“计算机中丢失MSVCR100.dll”的解决方案方法一:1、使用搜索引擎搜索“MSVCR100.dll”,选择一个进入下载;2、将下载下来的压缩文件解压打开;3、将MSVCR10..._abqus msvr100.dll

kthread_work和kthread_worker机制-程序员宅基地

文章浏览阅读1.4k次,点赞4次,收藏20次。最近在看spi的驱动,驱动中有一个队列化机制,看起来不是很懂,所以就整理了下这块的内容,即kthread_work队列化机制,其实也可以理解为一种内核线程机制。我们首先来分析一下下面两个结构体kthread_worker 和 kthread_work 。结构体分析kthread_worker数据结构定义在:include/linux/kthread.hstruct kth..._kthread_worker

【面经分享】Android 开发面经_android开发面经-程序员宅基地

文章浏览阅读3.2k次,点赞4次,收藏14次。持续了大半个月的面试终于结束了,年后回来,从2月9号到3月1号,一直陆陆续续有面试邀约,不得不说,一边在职承受工作压力,另一边还要承受面试找工作压力,双重压力下,多多少少有点难顶,但是,收获offer还是比较满意的,拿下了网易、小米的offer,着实有点可惜的是字节跳动,倒在了三面,只能说自己还是太菜,以后还需要继续努。这期间只投递了互联网中大厂,面试并不多,以下是我在这大半个月以来的面试经历,发出来总结一波,也供大家参考参考!面试均为Android开发,社招岗。_android开发面经

攻防世界-baby_web详解_攻防世界baby_web-程序员宅基地

文章浏览阅读8.5k次,点赞6次,收藏14次。baby_web题目描述:想想初始页面是哪个根据提示我们尝试/index.php页面:发现网页直接跳转到1.php我们尝试抓包分析抓包:(index.php)点 Foward放过当跳转到1.php时放到repeater模块发现flag但是隐藏了falg:flag{very_baby_web}..._攻防世界baby_web

WebClient 连接池配置_webclient连接池-程序员宅基地

文章浏览阅读6.5k次,点赞2次,收藏11次。背景项目中调用第三方接口,第三方接口响应时间不稳定,并且并发越大响应时间越长,如果使用BIO模式可能会导致服务器连接占用过高,所以采用WebClient NIO模式来调用第三方接口。连接池相关配置maxConnections:最大连接数,默认最大连接数为处理器数量*2(但最小值为16),最大只能设置为200,超过这个数值设置无效。pendingAcquireMaxCount:等待队列大小,默认是最大连接数的2倍,等待队列pendingAcquireMaxCount调大,同时处理的任务数等于最大连接数_webclient连接池

基于深度学习的番茄叶片病害检测系统(含UI界面、yolov8、Python代码、数据集)_深度学习叶片病害检测-程序员宅基地

文章浏览阅读1.9k次,点赞31次,收藏44次。本文将详细介绍如何以官方yolov8为主干,实现对鱼类的检测识别,且利用PyQt5设计了简约的系统UI界面。在界面中,您可以选择自己的视频文件、图片文件进行检测。此外,您还可以更换自己训练的主干模型,进行自己数据的检测。该系统界面优美,检测精度高,功能强大。它具备多目标实时检测,同时可以自由选择感兴趣的检测目标。本博文提供了完整的Python程序代码和使用教程,适合新入门的朋友参考。您可以在文末的下载链接中获取完整的代码资源文件。数据集总共包含以下类别,且已经分好文件夹,也提供转好的yolo。_深度学习叶片病害检测

随便推点

无感FOC电机控制代码,算法采用滑膜观测器,SVPWM控制_滑膜foc算法-程序员宅基地

文章浏览阅读482次,点赞8次,收藏8次。滑膜观测器算法通过对电机运行状态的准确估计,实现对电机的稳定控制,并能有效降低传感器的成本和复杂性。该代码经过精心设计和优化,通过对电机的电流、转子位置和速度等参数进行实时监测和反馈控制,实现对电机的精确控制。四、启动采用Vf 无感FOC电机的启动是电机运行的关键阶段,采用Vf启动策略可以有效提高电机的启动性能。通过本文的介绍,读者将能够全面了解无感FOC电机控制算法的原理和应用,为相关领域的研究和开发提供参考和指导。带原理图,SMO推导,附有相关的文档资料, matlab模型,电机控制资料。_滑膜foc算法

MPU6050欧拉角计算旋转后三维坐标平面与水平面(初始xoy平面)夹角算法(外旋)-程序员宅基地

文章浏览阅读1.4k次。通过欧拉角计算出旋转后的三维坐标系的各平面(旋转后得到的xoy平面、xoz平面、yoz平面)与水平面(初始xoy平面)夹角_mpu6050欧拉角

create-react-app中使用CodeMirror轻量级代码编辑器,实现自动提示,自动补全代码问题_@uiw/react-codemirror-程序员宅基地

文章浏览阅读7.5k次,点赞5次,收藏13次。构建create-react-app,这里忽略······安装 代码编辑器 CodeMirror 的轻量级 React 组件npm install @uiw/react-codemirror --save安装好了之后,就可以直接引入使用了,直接上代码:import CodeMirror from '@uiw/react-codemirror';import 'codemi..._@uiw/react-codemirror

Hadoop集群搭建,大数据开发开发入门与实战-程序员宅基地

文章浏览阅读836次,点赞22次,收藏11次。己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**

电商API数据接口1688alibaba接口item_search_img-按图搜索1688商品(拍立淘)接入演示-程序员宅基地

文章浏览阅读506次,点赞5次,收藏7次。如:https://img.alicdn.com/imgextra/i3/15353738/TB2HDHAqN9YBuNjy0FfXXXIsVXa_!请求参数:imgid=http://g-search3.alicdn.com/img/bao/uploaded/i4/O1CN01IDpcD81zHbpHs1YgT_!替换为您的应用的api_key和api_secret,将imgid替换为您要上传的图片文件路径。参数说明:imgid:图片地址(使用淘宝upload_img接口上传图片,返回图片地址)

C++ STL 如何调堆【两种方法】 看了就懂_stl 堆-程序员宅基地

文章浏览阅读2.9k次,点赞2次,收藏6次。C++ STL 堆的调取记住掉STL里的东西要在前面加上use namespace std;。1.优先队列这个堆我想应该是最常用的,因为写起来方便,但是时间效率上不高,往往比手写的多一个系数。所以本人不是很喜欢用。 需要用到algorithm这个库。定义: priority_queue<存储类型> 变量名称,例如priority_queue< int..._stl 堆

推荐文章

热门文章

相关标签