@Test public void testFromJson1() { String customContextStr = null; assertNull(JsonUtils.fromJson(customContextStr, new TypeToken<Map<String, String>>() { }.getType())); customContextStr = "abc"; assertNull(JsonUtils.fromJson(customContextStr, new TypeToken<Map<String, String>>() { }.getType())); customContextStr = "{\"key\":\"value\"}"; Map<String, String> expected = new HashMap<>(); expected.put("key", "value"); assertEquals(expected, JsonUtils.fromJson(customContextStr, new TypeToken<Map<String, String>>() { }.getType())); }
public static <T> T fromJson(String json, Type typeOfT) { try { return gson.fromJson(json, typeOfT); } catch (JsonParseException e) { LogUtils.warn(log, LogEvents.ExecutorEvent.COMMON, "json deserialize error", e); return null; } }
JsonUtils { public static <T> T fromJson(String json, Type typeOfT) { try { return gson.fromJson(json, typeOfT); } catch (JsonParseException e) { LogUtils.warn(log, LogEvents.ExecutorEvent.COMMON, "json deserialize error", e); return null; } } }
JsonUtils { public static <T> T fromJson(String json, Type typeOfT) { try { return gson.fromJson(json, typeOfT); } catch (JsonParseException e) { LogUtils.warn(log, LogEvents.ExecutorEvent.COMMON, "json deserialize error", e); return null; } }  }
JsonUtils { public static <T> T fromJson(String json, Type typeOfT) { try { return gson.fromJson(json, typeOfT); } catch (JsonParseException e) { LogUtils.warn(log, LogEvents.ExecutorEvent.COMMON, "json deserialize error", e); return null; } }  static Gson getGson(); static JsonParser getJsonParser(); static String toJson(Object src); static String toJson(Object src, Type typeOfSrc); static T fromJson(String json, Type typeOfT); static T fromJson(String json, Class<T> classOfT); }
JsonUtils { public static <T> T fromJson(String json, Type typeOfT) { try { return gson.fromJson(json, typeOfT); } catch (JsonParseException e) { LogUtils.warn(log, LogEvents.ExecutorEvent.COMMON, "json deserialize error", e); return null; } }  static Gson getGson(); static JsonParser getJsonParser(); static String toJson(Object src); static String toJson(Object src, Type typeOfSrc); static T fromJson(String json, Type typeOfT); static T fromJson(String json, Class<T> classOfT);  }