alibaba / alibaba/fastjson2

[BUG] JSONType注解在Android Kotlin 数据类上不起作用

Open
#2,782 0 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

### 问题描述
```
@JSONType(ignores = ["ref"])
data class Person(
var brand: Int = 0,
var cId: Long = 0,
var ref: Int = 0,
)

val result = JSON.toJSONString(person)
```
使用JSONType注解忽略ref字段的序列化和反序列化失效。ref字段仍然会被序列化。

### 环境信息

- OS信息: Xiaomi Pad 5 Pro 5G (Android 11)
- JDK信息:JetBrains Runtime version 17.0.9
- 版本信息:Fastjson2 2.0.51.android5

### 期待的正确结果
希望ref字段不会被序列化出来。

Contributor guide

Open the contributing guide

Research direction

Start with the Kotlin data-class example in this issue and reproduce the behavior using JSON.toJSONString with Fastjson2 2.0.51.android5. Trace how JSONType ignores are handled for Android Kotlin properties, then add or update a regression test showing that ref is omitted during serialization and deserialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.