mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix json.parse bug #1363
This commit is contained in:
parent
1deed5d9cf
commit
0800ffe1e5
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.5.7 (2021-01-06)
|
# 5.5.7 (2021-01-07)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
* 【core 】 DynaBean.create增加重载方法(pr#245@Gitee)
|
* 【core 】 DynaBean.create增加重载方法(pr#245@Gitee)
|
||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【core 】 修复CsvReader读取双引号未转义问题(issur#I2BMP1@Gitee)
|
* 【core 】 修复CsvReader读取双引号未转义问题(issur#I2BMP1@Gitee)
|
||||||
|
* 【json 】 JSONUtil.parse修复config无效问题(issur#1363@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package cn.hutool.http.server;
|
|||||||
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
|
import cn.hutool.core.thread.GlobalThreadPool;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.server.action.Action;
|
import cn.hutool.http.server.action.Action;
|
||||||
import cn.hutool.http.server.action.RootAction;
|
import cn.hutool.http.server.action.RootAction;
|
||||||
import cn.hutool.http.server.handler.ActionHandler;
|
import cn.hutool.http.server.handler.ActionHandler;
|
||||||
@ -53,6 +55,7 @@ public class SimpleServer {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
|
setExecutor(GlobalThreadPool.getExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,6 +66,8 @@ public class SimpleServer {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public SimpleServer addHandler(String path, HttpHandler handler) {
|
public SimpleServer addHandler(String path, HttpHandler handler) {
|
||||||
|
// 非/开头的路径会报错
|
||||||
|
path = StrUtil.addPrefixIfNot(path, StrUtil.SLASH);
|
||||||
this.server.createContext(path, handler);
|
this.server.createContext(path, handler);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* {@link com.sun.net.httpserver.HttpHandler} 实现包装
|
||||||
|
*/
|
||||||
|
package cn.hutool.http.server.handler;
|
@ -45,6 +45,10 @@ public class SimpleServerTest {
|
|||||||
response.write(request.getMultipart().getParamMap().toString(), ContentType.TEXT_PLAIN.toString());
|
response.write(request.getMultipart().getParamMap().toString(), ContentType.TEXT_PLAIN.toString());
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
.addAction("test/zeroStr", (req, res)->{
|
||||||
|
res.addHeader("Content-Length", "0".length() + "");
|
||||||
|
res.write("0");
|
||||||
|
})
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ public final class JSONUtil {
|
|||||||
json = (JSON) obj;
|
json = (JSON) obj;
|
||||||
} else if (obj instanceof CharSequence) {
|
} else if (obj instanceof CharSequence) {
|
||||||
final String jsonStr = StrUtil.trim((CharSequence) obj);
|
final String jsonStr = StrUtil.trim((CharSequence) obj);
|
||||||
json = StrUtil.startWith(jsonStr, '[') ? parseArray(jsonStr) : parseObj(jsonStr);
|
json = isJsonArray(jsonStr) ? parseArray(jsonStr, config) : parseObj(jsonStr, config);
|
||||||
} else if (obj instanceof Iterable || obj instanceof Iterator || ArrayUtil.isArray(obj)) {// 列表
|
} else if (obj instanceof Iterable || obj instanceof Iterator || ArrayUtil.isArray(obj)) {// 列表
|
||||||
json = new JSONArray(obj, config);
|
json = new JSONArray(obj, config);
|
||||||
} else {// 对象
|
} else {// 对象
|
||||||
|
Loading…
x
Reference in New Issue
Block a user