-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix for firstChar upper case getter method, field annotation not …
…work, for issue #638
- Loading branch information
Showing
2 changed files
with
42 additions
and
24 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
31 changes: 31 additions & 0 deletions
31
core/src/test/java/com/alibaba/fastjson2/issues/Issue638.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,31 @@ | ||
package com.alibaba.fastjson2.issues; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.annotation.JSONField; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue638 { | ||
@Test | ||
public void test() { | ||
Clothing clothing = new Clothing(); | ||
if (clothing.getTShirtType() == null) { | ||
clothing.setTShirtType(new ArrayList<>()); | ||
} | ||
clothing.getTShirtType().add("Sweater Vest"); | ||
assertEquals("{\"tShirtType\":[\"Sweater Vest\"]}", JSON.toJSONString(clothing)); | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public class Clothing { | ||
@JSONField(name = "tShirtType") | ||
private List<String> tShirtType; | ||
} | ||
} |