fastjson升级为fastjson2

(1) pom修改

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
</dependency>
为:
<dependency>
    <groupId>com.alibaba.fastjson2</groupId>
    <artifactId>fastjson2</artifactId>
</dependency>
    <dependency>
        <groupId>com.alibaba.fastjson2</groupId>
        <artifactId>fastjson2-extension-spring6</artifactId>
        <version>2.0.46</version>
    </dependency>

(2) import com.alibaba.fastjson.JSON; 替换为 import com.alibaba.fastjson2.JSON;

(3)getInnerMap:
Map<String, Object> innerMap = JSON.parseObject(JSONObject.toJSONString(obj)).getInnerMap();
替换为
Map<String, Object> innerMap = JSON.parseObject(JSONObject.toJSONString(obj), Map.class);
(4) import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
替换为:
import com.alibaba.fastjson2.support.spring6.data.redis.GenericFastJsonRedisSerializer;
(5) String original = JSONObject.toJSONString(innerMap, SerializerFeature.MapSortField);
替换为:
String original = JSONObject.toJSONString(innerMap, JSONWriter.Feature.MapSortField);
(6)String json = JSON.toJSONStringWithDateFormat(this, DateRangeQueryBuilder.TIME_FORMAT, SerializerFeature.WriteDateUseDateFormat);
替换为:String json = JSON.toJSONString(this, DateRangeQueryBuilder.TIME_FORMAT);
(6)JSONObject.toJSONString(map, SerializerFeature.SortField)
替换为:
JSONObject.toJSONString(userInfos)

相关推荐

  1. fastjson升级fastjson2

    2024-03-20 18:02:04       37 阅读
  2. fastjson

    2024-03-20 18:02:04       30 阅读
  3. <span style='color:red;'>FastJson</span>

    FastJson

    2024-03-20 18:02:04      25 阅读
  4. fastjson2 简单使用案例

    2024-03-20 18:02:04       43 阅读
  5. FastJson详解

    2024-03-20 18:02:04       19 阅读
  6. fastjson2 转换别名 null变空字符串

    2024-03-20 18:02:04       37 阅读
  7. fastjson2实现下划线与驼峰的自动映射

    2024-03-20 18:02:04       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-20 18:02:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-20 18:02:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-20 18:02:04       82 阅读
  4. Python语言-面向对象

    2024-03-20 18:02:04       91 阅读

热门阅读

  1. 设计模式(结构型设计模式——桥接模式)

    2024-03-20 18:02:04       38 阅读
  2. Spring Data访问Elasticsearch----Elasticsearch审计Auditing

    2024-03-20 18:02:04       44 阅读
  3. C语言实现红黑树

    2024-03-20 18:02:04       37 阅读
  4. Python实现ANSI CRC16校验算法

    2024-03-20 18:02:04       40 阅读
  5. JNI入门学习 对象,接口回调

    2024-03-20 18:02:04       38 阅读
  6. 2024最新华为OD机试试题库全 -【执行时长】- C卷

    2024-03-20 18:02:04       38 阅读
  7. 为什么守护网络安全需要用高防IP

    2024-03-20 18:02:04       34 阅读
  8. linux网络常用命令

    2024-03-20 18:02:04       34 阅读
  9. 力扣每日练习(3.16)补

    2024-03-20 18:02:04       42 阅读