This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7f1f5c
commit 2fa8ee0
Showing
4 changed files
with
63 additions
and
6 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
9 changes: 9 additions & 0 deletions
9
src/test/java/com/alibaba/fastjson/serializer/issues3601/TestEntity.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,9 @@ | ||
package com.alibaba.fastjson.serializer.issues3601; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class TestEntity { | ||
private TestEnum testEnum; | ||
private String testName; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/java/com/alibaba/fastjson/serializer/issues3601/TestEnum.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,32 @@ | ||
package com.alibaba.fastjson.serializer.issues3601; | ||
|
||
import com.alibaba.fastjson.annotation.JSONField; | ||
|
||
public enum TestEnum { | ||
|
||
@JSONField | ||
test1("1"), | ||
// @JSONField | ||
test2("2"); | ||
|
||
private String title; | ||
|
||
TestEnum(String title) { | ||
this.title = title; | ||
} | ||
|
||
// @JSONField | ||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
private Integer i = 100; | ||
|
||
@JSONField | ||
public Integer getI() { | ||
return i; | ||
} | ||
|
||
} | ||
|
||
|
19 changes: 19 additions & 0 deletions
19
src/test/java/com/alibaba/fastjson/serializer/issues3601/TestIssue3601.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,19 @@ | ||
package com.alibaba.fastjson.serializer.issues3601; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class TestIssue3601 { | ||
|
||
@Test | ||
public void enumTest() { | ||
TestEntity testEntity = new TestEntity(); | ||
testEntity.setTestName("ganyu"); | ||
testEntity.setTestEnum(TestEnum.test1); | ||
String json = JSON.toJSONString(testEntity); | ||
System.out.println(json); | ||
Assert.assertEquals("{\"testEnum\":\"test1\",\"testName\":\"ganyu\"}", json); | ||
} | ||
|
||
} |