这行代码给出了弃用警告:
mapper.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true);
Run Code Online (Sandbox Code Playgroud)
这不能编译
mapper.configure(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS, true);
Run Code Online (Sandbox Code Playgroud)
因为JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS这四种Feature类型中任何一种的子类都不ObjectMapper支持。
在 Jackson 2.12 中启用此功能的正确做法是什么?
似乎没有任何 API 接受JacksonFeature或JsonReadFeature作为参数。
DeserializationConfig接受作为参数,但在通过调用 获取新实例后FormatFeature无法更改此属性。ObjectMapperwithFeatures()
JsonReadFeature唯一的解决方案似乎是从不再弃用的功能中获取该功能:
mapper.enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS.mappedFeature());
Run Code Online (Sandbox Code Playgroud)
(注意枚举末尾的方法调用)。
| 归档时间: |
|
| 查看次数: |
5109 次 |
| 最近记录: |