Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

开启@JSONField的unwrapped功能使序列化后的属性名丢失#2753

Merged
wenshao merged 2 commits intoalibaba:masterfrom
Omega-Ariston:fix-unwrapped_lost_name
Sep 19, 2019
Merged

开启@JSONField的unwrapped功能使序列化后的属性名丢失#2753
wenshao merged 2 commits intoalibaba:masterfrom
Omega-Ariston:fix-unwrapped_lost_name

Conversation

@Omega-Ariston
Copy link
Copy Markdown
Collaborator

简单的复现用例:

    public void test_empty() throws Exception {
        Health vo = new Health();
        vo.id = 123;

        String text = JSON.toJSONString(vo);
        Assert.assertEquals("{\"id\":123}", text);  //输出"{123}",属性名"id"丢失
    }

    public static class Health {
        @JSONField(unwrapped = true)
        public int id;
    }

目前已知unwrap只应该作用于map和javabean,所以在JavaBeanSerializer.write()方法中写属性名的地方加了一条判断

@Omega-Ariston
Copy link
Copy Markdown
Collaborator Author

本地构建测试通过,失败的用例还是那个ci时区问题

@codecov-io
Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@40eed46). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2753   +/-   ##
========================================
  Coverage          ?   80.1%           
  Complexity        ?    7080           
========================================
  Files             ?     145           
  Lines             ?   26716           
  Branches          ?    6379           
========================================
  Hits              ?   21401           
  Misses            ?    3482           
  Partials          ?    1833
Impacted Files Coverage Δ Complexity Δ
...libaba/fastjson/serializer/JavaBeanSerializer.java 83.25% <100%> (ø) 188 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40eed46...3de2f9f. Read the comment docs.

@wenshao wenshao merged commit 9d11d07 into alibaba:master Sep 19, 2019
@Omega-Ariston Omega-Ariston deleted the fix-unwrapped_lost_name branch September 20, 2019 08:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants