mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -124,7 +124,7 @@ public class JSONConverter implements Converter {
|
||||
* <li>String: 转换为相应的对象,"和'包围的字符串返回原字符串,""返回{@code null}</li>
|
||||
* <li>Array、Iterable、Iterator:转换为JSONArray</li>
|
||||
* <li>Bean对象:转为JSONObject</li>
|
||||
* <li>Number:返回原对象</li>
|
||||
* <li>Number、Boolean:返回原对象</li>
|
||||
* <li>null:返回{@code null}</li>
|
||||
* </ul>
|
||||
*
|
||||
@@ -138,7 +138,7 @@ public class JSONConverter implements Converter {
|
||||
return null;
|
||||
}
|
||||
final JSON json;
|
||||
if (obj instanceof JSON || obj instanceof Number) {
|
||||
if (obj instanceof JSON || obj instanceof Number || obj instanceof Boolean) {
|
||||
return obj;
|
||||
} else if (obj instanceof CharSequence) {
|
||||
final String jsonStr = StrUtil.trim((CharSequence) obj);
|
||||
|
@@ -2,6 +2,7 @@ package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.date.DateUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.map.MapUtil;
|
||||
import org.dromara.hutool.core.math.NumberUtil;
|
||||
import org.dromara.hutool.json.serialize.JSONStringer;
|
||||
@@ -334,4 +335,10 @@ public class JSONUtilTest {
|
||||
private Byte[] d = new Byte[0];
|
||||
private Byte[] e = new Byte[1];
|
||||
}
|
||||
|
||||
@Test
|
||||
void toJsonStrOfBooleanTest() {
|
||||
final String jsonStr = JSONUtil.toJsonStr(true);
|
||||
Assertions.assertEquals("true", jsonStr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user