mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix code
This commit is contained in:
parent
0a768ad2c6
commit
80c3966211
@ -1,8 +1,8 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
/**
|
||||
* <code>JSONString</code>接口定义了一个<code>toJSONString()</code><br>
|
||||
* 实现此接口的类可以通过实现<code>toJSONString()</code>方法来改变转JSON字符串的方式。
|
||||
* {@code JSONString}接口定义了一个{@code toJSONString()}<br>
|
||||
* 实现此接口的类可以通过实现{@code toJSONString()}方法来改变转JSON字符串的方式。
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
|
@ -35,7 +35,7 @@ public class JSONSupport implements JSONString{
|
||||
* @return 美化的JSON
|
||||
*/
|
||||
public String toPrettyString() {
|
||||
return toJSON().toJSONString(4);
|
||||
return toJSON().toStringPretty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,13 +4,13 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.json.test.bean.Price;
|
||||
import cn.hutool.json.test.bean.UserA;
|
||||
import cn.hutool.json.test.bean.UserC;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -165,11 +165,11 @@ public class JSONUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleTest2() {
|
||||
String json = "{\"test\": 12.00}";
|
||||
final JSONObject jsonObject = JSONUtil.parseObj(json);
|
||||
jsonObject.set("test2", new BigInteger("12"));
|
||||
Console.log(jsonObject);
|
||||
public void customValueTest() {
|
||||
final JSONObject jsonObject = JSONUtil.createObj()
|
||||
.set("test2", (JSONString) () -> NumberUtil.decimalFormat("#.0", 12.00D));
|
||||
|
||||
Assert.assertEquals("{\"test2\":12.0}", jsonObject.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user