Jackson XmlMaaper无法解码null Double

问题描述

我遇到一个奇怪的杰克逊问题。 XmlMapper无法反序列化自己序列化的内容。 而且只有在Double数组中为null时才会发生错误。重现此问题的示例测试用例如下:

getA()

序列化的有效负载如下:

B

错误是:

@Test
public void testDerSer(){
    Double[] testDouble = new Double[]{null,null,3.0d,34.5d};
    try {
        ObjectMapper xmlMapper = new XmlMapper();
        byte[] bytes = xmlMapper.writeValueAsBytes(testDouble);
        System.out.println(new String(bytes));
        Double[] doubles = xmlMapper.readValue(bytes,Double[].class);
        System.out.println(doubles);
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)