alibaba / fastjson2

🚄 FASTJSON2 is a Java JSON library with excellent performance.
Apache License 2.0
3.79k stars 495 forks source link

[BUG] UnsignedLong类型的支持 #2958

Closed Taogang00 closed 2 months ago

Taogang00 commented 2 months ago

问题描述

使用clickhouse-java 的jdbc驱动,对select count(1) 查询的结果序列化返回数据时,不支持UnsignedLong等UnsignedXxx 类型,目前看其他json 框架均支持

环境信息

重现步骤

如何操作可以重现该问题:

  1. run main
  2. 代码

        <dependency>
            <groupId>com.clickhouse</groupId>
            <artifactId>clickhouse-jdbc</artifactId>
            <version>0.6.5</version>
            <classifier>http</classifier>
        </dependency>
    public static void main(String[] args) throws JsonProcessingException {
        UnsignedLong unsignedLong = UnsignedLong.valueOf(123456789L);
    
        Map<String, Object> map = new HashMap<>();
        map.put("count", unsignedLong);
    
        //fastjson2
        System.out.println("fastjson2:  " + JSONObject.toJSONString(map));
    
        //jackson
        ObjectMapper objectMapper = new ObjectMapper();
        System.out.println("jackson:  " + objectMapper.writeValueAsString(map));
    
        //hutool-json
        System.out.println("hutool-json:  " + JSONUtil.toJsonStr(map));
    
        //gson
        Gson gson = new GsonBuilder().create();
        System.out.println("gson:  " + gson.toJson(map));
    }

期待的正确结果

正常输出count

相关日志输出

fastjson2: {"count":{}} jackson: {"count":123456789} hutool-json: {"count":123456789} gson: {"count":{"value":123456789}}

附加信息

image

wenshao commented 2 months ago

https://github.com/alibaba/fastjson2/releases/tag/2.0.53 问题已修复,请用新版本