alibaba / alibaba/fastjson2

Java Obejct 转 Json 在只有get方法的情况下存在问题

Open
#2,731 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

我发现 当一些复杂的 Object 比如 含有一些get 方法但是没有对应参数的情况下 如果 含有 @Data 的情况fastjson 和 fatsjson2 转出来的String 会有问题 会多出来 get方法对应的那几个参数 如 status buinessType 导致想要转回对象时报错。Gson则没有这个问题,详情请看附件。

![621D6E94@7704C17C DA907266](https://github.com/alibaba/fastjson2/assets/86043201/479c2c48-de27-4543-93c3-fe0ede31b5f7)
![7D1A07D1@26C7E059 DA907266](https://github.com/alibaba/fastjson2/assets/86043201/ce203d18-0ad0-46a1-8aeb-45e4601eb885)

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named; start by reconstructing the attached example with a complex object that has getter-only properties and @Data. Compare the fastjson and fastjson2 output with Gson, then verify that the extra getter-derived fields are absent and the JSON can be converted back to the object.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.