java ObjectMapper.readValue 可以返回空值吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34296761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:42:57  来源:igfitidea点击:

ObjectMapper.readValue can return null value?

javajsonHymanson

提问by mik

ObjectMapper.readValue in Hymanson library does return null value. In what case does it return null object? It found that from codebase.

Hymanson 库中的 ObjectMapper.readValue 确实返回空值。在什么情况下它返回空对象?它从代码库中发现。

<dependency>
    <groupId>org.codehaus.Hymanson</groupId>
    <artifactId>Hymanson-mapper-asl</artifactId>
    <version>1.9.9</version>
</dependency>

You can browse through ObjectMapper class to dig in more details

您可以浏览 ObjectMapper 类以深入了解更多细节

采纳答案by StaxMan

readValue()returns nullfor JSON input consisting of JSON value null. It does not return nullfor any other case: missing input (for example) would be rewarded by an exception; and no deserializer produces nullby default.

readValue()返回null由 JSON value 组成的 JSON 输入null。它不会null在任何其他情况下返回:丢失的输入(例如)将获得异常奖励;并且null默认情况下没有解串器产生。