Commit 442276c3 authored by yanzg's avatar yanzg

1.3版本修改,增加删除功能

parent 26c69c2a
...@@ -84,7 +84,16 @@ public class JsonHelper { ...@@ -84,7 +84,16 @@ public class JsonHelper {
* @throws Exception 转换结果发生异常 * @throws Exception 转换结果发生异常
*/ */
public static <T> T deserialize(String json, Class<T> type) { public static <T> T deserialize(String json, Class<T> type) {
return JSON.parseObject(json, type); if (isException) {
return JSON.parseObject(json, type);
} else {
try {
return JSON.parseObject(json, type);
} catch (RuntimeException ex) {
ex.printStackTrace();
return null;
}
}
} }
/** /**
...@@ -97,7 +106,16 @@ public class JsonHelper { ...@@ -97,7 +106,16 @@ public class JsonHelper {
* @throws Exception 转换结果发生异常 * @throws Exception 转换结果发生异常
*/ */
public static <T> T deserialize(String json, TypeReference<T> type) { public static <T> T deserialize(String json, TypeReference<T> type) {
return JSON.parseObject(json, type); if (isException) {
return JSON.parseObject(json, type);
} else {
try {
return JSON.parseObject(json, type);
} catch (RuntimeException ex) {
ex.printStackTrace();
return null;
}
}
} }
/** /**
...@@ -116,7 +134,16 @@ public class JsonHelper { ...@@ -116,7 +134,16 @@ public class JsonHelper {
if (json.startsWith(OBJECT_START_FLAG)) { if (json.startsWith(OBJECT_START_FLAG)) {
json = String.format("[%s]", json); json = String.format("[%s]", json);
} }
return JSON.parseObject(json, type); if (isException) {
return JSON.parseObject(json, type);
} else {
try {
return JSON.parseObject(json, type);
} catch (RuntimeException ex) {
ex.printStackTrace();
return null;
}
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment