-
Notifications
You must be signed in to change notification settings - Fork 514
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 WriteLongAsString, for issue #961
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 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
32 changes: 32 additions & 0 deletions
32
core/src/test/java/com/alibaba/fastjson2/issues/Issue961.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.fastjson2.issues; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue961 { | ||
@Test | ||
public void test() { | ||
User user1 = new User(1038L); | ||
String res1 = JSON.toJSONString(user1, JSONWriter.Feature.WriteLongAsString); | ||
assertEquals("{\"id\":\"1038\"}", res1); | ||
|
||
User user2 = new User(1039L); | ||
String res2 = JSON.toJSONString(user2, JSONWriter.Feature.WriteLongAsString); | ||
assertEquals("{\"id\":\"1039\"}", res2); | ||
} | ||
|
||
public class User { | ||
private long id; | ||
|
||
public User(long id) { | ||
this.id = id; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
} | ||
} |