mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
JSONConfig增加setWriteLongAsString可选是否将Long写出为String类型
This commit is contained in:
22
hutool-json/src/test/java/cn/hutool/json/Issue3541Test.java
Normal file
22
hutool-json/src/test/java/cn/hutool/json/Issue3541Test.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Issue3541Test {
|
||||
@Test
|
||||
public void longToStringTest() {
|
||||
Demo demo = new Demo();
|
||||
demo.setId(1227690722069581409L);
|
||||
demo.setName("hutool");
|
||||
String jsonStr = JSONUtil.toJsonStr(demo, JSONConfig.create().setWriteLongAsString(true));
|
||||
Assert.assertEquals("{\"id\":\"1227690722069581409\",\"name\":\"hutool\"}", jsonStr);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Demo {
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user