alibaba / alibaba/fastjson2

[QUESTION] 有没有介绍尽可能贴合fastjson1行为的使用方式的文档

Open
#7,735 2 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 请描述您的问题
我们目前因为安全原因强制从fastjson升级到fastjson2 2.0.63。 我们在升级过程中发现fastjson2存在非常多的与fastjson行为不一致的处理, 导致为了兼容生产环境做了很多事情。 官方是否有提供文档/例子说明如何才能尽可能的让fastjson2 的序列化/反序列化行为尽可能与fastjson行为一致的用法? 以下是我们目前遇到的问题。 ~~说实话, 这种不向前兼容想一出是一出的更新,真的很不软件工程~~

- 默认不再输出@type字段
序列化增加配置```JSONWriter.Feature.WriteClassName```
- WriteClassName状态数值类型末尾会添加字母标注java类型。
序列化增加配置```JSONWriter.Feature.NotWriteNumberClassName```
- fastjson原本不会处理jackson,gson的注解, fastjson2突然能认出来了。
``
###序列化增加代码
JSONFactory.setUseJacksonAnnotation(false);
JSONFactory.setUseGsonAnnotation(false);
``
- fastjson反序列化方可以识别非法json key 111:"data", 但是fastjson2只认识合法json key "111":"data". 我们让发送方替换成jackson了
- fastjson1 → fastjson2 对「抽象类型字段」的行为发生了静默变更。 这是同事提交的一个问题, 我没有细看, 请问这又是何意味?

其它还有什么不一致的行为需要处理?

~~如果可以的话, 我更新希望开发组能提供一个平滑的将项目从fastjson/fastjson2迁移到jackson/gson的官方指导步骤, 谢谢🙏~~

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the JSONWriter.Feature options WriteClassName and NotWriteNumberClassName, the JSONFactory annotation settings, and the reported abstract-type behavior. Document the fastjson-to-fastjson2 compatibility settings and known differences described in the issue, with examples showing how to preserve the older behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.