This repository has been archived by the owner on Jun 26, 2022. It is now read-only.
forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Bug of issue alibaba#3672, ObjectArrayCodec's PrettyFormat do not…
… transfer array id to write(), so it will appear null. <type>: - [x] Bug fix - [x] This change requires a documentation update Signed-off-by: Certseeds <[email protected]>
- Loading branch information
Showing
3 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3672.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.alibaba.json.bvt.issue_3600; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.serializer.SerializerFeature; | ||
import com.google.common.collect.Lists; | ||
import lombok.Data; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Issue3672 { | ||
@Test | ||
public void test1() { | ||
Issue3672Root root = new Issue3672Root(); | ||
Issue3672A a = new Issue3672A(); | ||
Issue3672B b = new Issue3672B(); | ||
Issue3672C c = new Issue3672C(); | ||
Issue3672D d = new Issue3672D(); | ||
root.setA(a); | ||
a.setB(Lists.newArrayList(b).toArray()); | ||
b.setC(c); | ||
c.setD(d); | ||
d.setE(Lists.newArrayList(c)); | ||
Assert.assertFalse(JSON.toJSONString(root).contains("null")); | ||
Assert.assertFalse(JSON.toJSONString(root, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue).contains("null")); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
Issue3672Root2 root = new Issue3672Root2(); | ||
Issue3672A2 a = new Issue3672A2(); | ||
Issue3672B b = new Issue3672B(); | ||
Issue3672C c = new Issue3672C(); | ||
Issue3672D d = new Issue3672D(); | ||
root.setA(a); | ||
a.setB(Lists.newArrayList(b).toArray(new Issue3672B[0])); | ||
b.setC(c); | ||
c.setD(d); | ||
d.setE(Lists.newArrayList(c)); | ||
Assert.assertFalse(JSON.toJSONString(root).contains("null")); | ||
Assert.assertFalse(JSON.toJSONString(root, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue).contains("null")); | ||
} | ||
|
||
@Data | ||
private class Issue3672Root { | ||
private Issue3672A a; | ||
} | ||
|
||
@Data | ||
private class Issue3672Root2 { | ||
private Issue3672A2 a; | ||
} | ||
|
||
@Data | ||
private class Issue3672A { | ||
private Object[] b; | ||
} | ||
|
||
@Data | ||
private class Issue3672A2 { | ||
private Issue3672B[] b; | ||
} | ||
|
||
@Data | ||
private class Issue3672B { | ||
private Issue3672C c; | ||
} | ||
|
||
@Data | ||
private class Issue3672C { | ||
private Issue3672D d; | ||
} | ||
|
||
@Data | ||
private class Issue3672D { | ||
private ArrayList<Issue3672C> e; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters