Commit 575fa2d2 authored by Quxl's avatar Quxl
parents 4e4f75fc 9a24080a
package com.egolm.common; package com.egolm.common;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
public class GsonUtil { public class GsonUtil {
...@@ -19,6 +18,7 @@ public class GsonUtil { ...@@ -19,6 +18,7 @@ public class GsonUtil {
public static Map<String, Object> toMap(String json) { public static Map<String, Object> toMap(String json) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Map<?, ?> jsonMap = GsonUtil.gson.fromJson(json, Map.class); Map<?, ?> jsonMap = GsonUtil.gson.fromJson(json, Map.class);
if(jsonMap != null) { if(jsonMap != null) {
for(Object key : jsonMap.keySet()) { for(Object key : jsonMap.keySet()) {
...@@ -42,6 +42,6 @@ public class GsonUtil { ...@@ -42,6 +42,6 @@ public class GsonUtil {
public static List<?> toList(String json) { public static List<?> toList(String json) {
return GsonUtil.gson.fromJson(json, List.class); return GsonUtil.gson.fromJson(json, List.class);
} }
} }
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