@Test public void testGetGson() { assertNotNull(JsonUtils.getGson().fromJson("{}", ExecutorConfig.class)); try { JsonUtils.getGson().fromJson("abc", ExecutorConfig.class); fail("cannot happen"); } catch (Exception e) { assertTrue(e instanceof JsonParseException); } assertNotNull(JsonUtils.getGson().fromJson("{}", new TypeToken<Map<String, String>>() { }.getType())); try { JsonUtils.getGson().fromJson("abc", new TypeToken<Map<String, String>>() { }.getType()); fail("cannot happen"); } catch (Exception e) { assertTrue(e instanceof JsonParseException); } assertNotNull(JsonUtils.getGson().fromJson("{}", SaturnJobReturn.class)); try { JsonUtils.getGson().fromJson("abc", SaturnJobReturn.class); fail("cannot happen"); } catch (Exception e) { assertTrue(e instanceof JsonParseException); } Map<String, Object> obj = JsonUtils.getGson() .fromJson("{\"a\":true, \"b\":1}", new TypeToken<Map<String, Object>>() { }.getType()); assertNotNull(obj); assertTrue(obj.containsKey("a")); assertEquals(true, obj.get("a")); assertTrue(obj.containsKey("b")); assertEquals(1.0, obj.get("b")); try { JsonUtils.getGson().fromJson("abc", new TypeToken<Map<String, Object>>() { }.getType()); fail("cannot happen"); } catch (Exception e) { assertTrue(e instanceof JsonParseException); } assertNull(JsonUtils.getGson().fromJson("", new TypeToken<Map<String, Object>>() { }.getType())); String src = null; assertNull(JsonUtils.getGson().fromJson(src, new TypeToken<Map<String, Object>>() { }.getType())); }
public static Gson getGson() { return gson; }
JsonUtils { public static Gson getGson() { return gson; } }
JsonUtils { public static Gson getGson() { return gson; }  }
JsonUtils { public static Gson getGson() { return gson; }  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 Gson getGson() { return gson; }  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);  }