反序列化

master
jiahuiwen 2021-10-27 18:35:06 +08:00
parent ed58227588
commit 57cbc38a10
1 changed files with 8 additions and 7 deletions

View File

@ -18,7 +18,7 @@ public class JsonUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(JsonUtil.class);
private static JsonUtil jsonUtil;
private Gson gson = new Gson();
private static Gson gson = new Gson();
private static class InnerClass {
private static final JsonUtil SINGLETON = new JsonUtil();
@ -68,12 +68,13 @@ public class JsonUtil {
public static HaoGameParamBean serializeToObject(String str) throws IOException, ClassNotFoundException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes("UTF-8"));
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
HaoGameParamBean object = (HaoGameParamBean) objectInputStream.readObject();
objectInputStream.close();
byteArrayInputStream.close();
return object;
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes("UTF-8"));
// ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
// HaoGameParamBean object = (HaoGameParamBean) objectInputStream.readObject();
// objectInputStream.close();
// byteArrayInputStream.close();
HaoGameParamBean haoGameParamBean = gson.fromJson(str, HaoGameParamBean.class);
return haoGameParamBean;
}
public SortedMap<String, String> getParameterMapYX(HttpServletRequest request) {