diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/JsonUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/JsonUtil.java index 040a0ae..5247eff 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/JsonUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/JsonUtil.java @@ -132,6 +132,30 @@ public class JsonUtil { /** * @auther HuJiaqi + * @createTime 2016年12月12日 15时47分 + * @discription 获取map,处理总产程类似使用-"{\"h\":5,\"m\":0}",不按规则使用则返回null + */ + public static Map getMap(String str) { + if (StringUtils.isEmpty(str)) { + return null; + } + try { + HashMap data = new HashMap<>(); + JSONObject jsonObject = JSONObject.fromObject(str); + Iterator it = jsonObject.keys(); + while (it.hasNext()) { + String key = String.valueOf(it.next()); + String value = jsonObject.get(key).toString(); + data.put(key, value); + } + return data; + } catch (Exception e) { + return null; + } + } + + /** + * @auther HuJiaqi * @createTime 2016年12月12日 15时11分 * @discription 获取双层map,处理产程类似使用-"{\"one\":{},\"two\":{},\"three\":{\"h\":55,\"m\":5}}",不按规则使用则返回null */ @@ -150,7 +174,7 @@ public class JsonUtil { Map value = new HashMap<>(); while (it1.hasNext()) { String key1 = String.valueOf(it1.next()); - String value1 = jsonObject1.get(key1) == null ? "" : jsonObject1.get(key1).toString(); + String value1 = jsonObject1.get(key1).toString(); value.put(key1, value1); } data.put(key, value);