mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add config
This commit is contained in:
@@ -173,6 +173,23 @@ public class JSONUtilTest {
|
||||
Assert.assertEquals("{\"test2\":12.0}", jsonObject.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setStripTrailingZerosTest() {
|
||||
// 默认去除多余的0
|
||||
final JSONObject jsonObjectDefault = JSONUtil.createObj()
|
||||
.set("test2", 12.00D);
|
||||
Assert.assertEquals("{\"test2\":12}", jsonObjectDefault.toString());
|
||||
|
||||
// 不去除多余的0
|
||||
final JSONObject jsonObject = JSONUtil.createObj(JSONConfig.create().setStripTrailingZeros(false))
|
||||
.set("test2", 12.00D);
|
||||
Assert.assertEquals("{\"test2\":12.0}", jsonObject.toString());
|
||||
|
||||
// 去除多余的0
|
||||
jsonObject.getConfig().setStripTrailingZeros(true);
|
||||
Assert.assertEquals("{\"test2\":12}", jsonObject.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseObjTest() {
|
||||
// 测试转义
|
||||
|
Reference in New Issue
Block a user