-
Notifications
You must be signed in to change notification settings - Fork 495
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
Showing
3 changed files
with
38 additions
and
2 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
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
35 changes: 35 additions & 0 deletions
35
core/src/test/java/com/alibaba/fastjson2/issues_2900/Issue2901.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,35 @@ | ||
package com.alibaba.fastjson2.issues_2900; | ||
|
||
import com.alibaba.fastjson2.JSONObject; | ||
import com.alibaba.fastjson2.annotation.JSONField; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class Issue2901 { | ||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
public class User { | ||
@JSONField(name = "user_name") | ||
private String userName; | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"userName='" + userName + '\'' + | ||
'}'; | ||
} | ||
} | ||
|
||
void test() { | ||
String str1 = "{\n" + | ||
"\"user_name\":\"zs\"\n" + | ||
"}"; | ||
User user = JSONObject.parseObject(str1, User.class); | ||
assertNotNull(user); | ||
assertEquals(user.getUserName(), "zs"); | ||
} | ||
} |