Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[BUG] @JsonUnwrapped加在方法上时未生效 #2846

Closed
liuzhengyang opened this issue Jul 31, 2024 · 3 comments
Closed

[BUG] @JsonUnwrapped加在方法上时未生效 #2846

liuzhengyang opened this issue Jul 31, 2024 · 3 comments
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@liuzhengyang
Copy link

问题描述

@JsonUnwrapped加在方法上时未生效

环境信息

请填写以下信息:

  • OS信息: mac
  • JDK信息:jdk17
  • 版本信息:Fastjson2 2.0.52

重现步骤

可复现代码

public class FastJsonTest {

    @Test
    public void testFastJson() throws Exception {
        CombineView combineView = new CombineView();
        String jacksonResult = new ObjectMapper().writeValueAsString(combineView);
        String fastjsonResult = JSON.toJSONString(new CombineView());
        Assert.assertEquals(jacksonResult, fastjsonResult);
    }

    static class CombineView {
        @JsonUnwrapped
        public View1 author() {
            return new View1();
        }
    }

    static class View1 {
        public String getAuthorName() {
            return "name";
        }
    }
}

结果

org.junit.ComparisonFailure: 
Expected :{"authorName":"name"}
Actual   :{}

期待的正确结果

正确处理方法上的@JsonUnwrapped,兼容jackson

相关日志输出

org.junit.ComparisonFailure: 
Expected :{"authorName":"name"}
Actual   :{}

附加信息

@liuzhengyang liuzhengyang added the bug Something isn't working label Jul 31, 2024
@wenshao wenshao self-assigned this Aug 2, 2024
@wenshao
Copy link
Member

wenshao commented Aug 8, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.53-SNAPSHOT/
问题已修复,请帮忙用2.0.53-SNAPSHOT帮忙验证,2.0.53版本预计在这个周末发布

@wenshao wenshao added this to the 2.0.53 milestone Aug 8, 2024
@wenshao wenshao added the fixed label Aug 8, 2024
@liuzhengyang
Copy link
Author

验证已经修复,thanks

@wenshao
Copy link
Member

wenshao commented Sep 16, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants