Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] #2578 Serialize java.awt.Color #2739

Closed
Cooper-Zhong opened this issue Jun 25, 2024 · 1 comment
Closed

[BUG] #2578 Serialize java.awt.Color #2739

Cooper-Zhong opened this issue Jun 25, 2024 · 1 comment
Labels
bug Something isn't working fixed
Milestone

Comments

@Cooper-Zhong
Copy link
Contributor

问题描述

#2578 , 1.x 支持但fastjson 2.0.51兼容有问题。

环境信息

  • OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [Openjdk 17.0.6]
  • 版本信息:[Fastjson 2.0.51]

重现步骤

import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;

import java.awt.Color;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue2578 {
    @Test
    public void test() {
        Color blue = Color.BLUE;
        String colorStr = JSON.toJSONString(blue);
        assertEquals("{\"r\":0,\"g\":0,\"b\":255,\"alpha\":255}", colorStr);
        Color color = JSON.parseObject(colorStr, Color.class);
        assertEquals(blue, color);
    }
}

期待的正确结果

Expected :{"r":0,"g":0,"b":255,"alpha":255}
Actual :{"rgb":-16776961}

@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label Jun 25, 2024
@wenshao wenshao modified the milestones: 2.0.52, 2.0.53 Jun 30, 2024
@wenshao wenshao modified the milestones: 2.0.53, 2.0.54 Sep 16, 2024
@wenshao wenshao added the fixed label Jan 1, 2025
@wenshao
Copy link
Member

wenshao commented Jan 12, 2025

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

@wenshao wenshao closed this as completed Jan 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants