### Question:
JsonObjectUtil { public static <T> String getAsJsonString(T source, int depth) { Gson gson = new Gson(); JsonObject object = toJsonObject(source, depth); return gson.toJson(object); } private  JsonObjectUtil(); static JsonObject toJsonObject(String json); static JsonObject toJsonObject(Resource resource); static JsonObject toJsonObject(Object source); static JsonObject toJsonObject(T source, int depth); static void pruneToDepth(JsonObject obj, int depth); static String getAsJsonString(T source, int depth); static boolean isSingularElement(JsonElement elem); static Optional<JsonElement> getOptional(JsonObject obj, String prop); static T getOptionalProperty(JsonObject obj, String prop, Function<JsonElement, T> getter, T defaultValue); static Optional<JsonObject> getOptionalObject(JsonObject obj, String prop); static String getString(JsonObject obj, String prop, String defaultValue); static String getString(JsonObject obj, String prop); static Long getLong(JsonObject obj, String prop, Long defaultValue); static Long getLong(JsonObject obj, String prop); static Integer getInteger(JsonObject obj, String prop, Integer defaultValue); static Integer getInteger(JsonObject obj, String prop); static Boolean getBoolean(JsonObject obj, String prop, Boolean defaultValue); static Boolean getBoolean(JsonObject obj, String prop);  }### Answer:
@Test public void testGetAsJsonString() { String json = "{\"level\":1.0,\"l2\":{\"level\":2.0,\"l3\":{\"level\":3.0}}}"; String conv = JsonObjectUtil.getAsJsonString(json, 3); assertEquals(json, conv); }