@Test public void double_shallow() { String template = "{ \"a\" : \"{{value}}\", \"b\": \"{{value}}\"}"; JsonObject document = (JsonObject) new JsonParser().parse(template); Map<String, String> paths = JsonUtil.getJsonPathsForTemplating(document); assertEquals(2, paths.size()); Object a = paths.get("$.a"); assertNotNull(a); assertEquals("{{value}}", a.toString()); Object b = paths.get("$.b"); assertNotNull(b); assertEquals("{{value}}", a.toString()); }
public static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root) { Map<String, String> paths = new HashMap<>(); searchJsonForTemplate(root, paths, "$"); return paths; }
JsonUtil { public static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root) { Map<String, String> paths = new HashMap<>(); searchJsonForTemplate(root, paths, "$"); return paths; } }
JsonUtil { public static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root) { Map<String, String> paths = new HashMap<>(); searchJsonForTemplate(root, paths, "$"); return paths; } private  JsonUtil(/* empty */); }
JsonUtil { public static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root) { Map<String, String> paths = new HashMap<>(); searchJsonForTemplate(root, paths, "$"); return paths; } private  JsonUtil(/* empty */); static boolean updateField(JsonElement json, String field, JsonElement value); static boolean updateField(JsonElement json, String field, String value); static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root); static Map<String, String> getJsonPathsForTemplating(JsonObject json); }
JsonUtil { public static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root) { Map<String, String> paths = new HashMap<>(); searchJsonForTemplate(root, paths, "$"); return paths; } private  JsonUtil(/* empty */); static boolean updateField(JsonElement json, String field, JsonElement value); static boolean updateField(JsonElement json, String field, String value); static Map<String, String> getJsonPathsForTemplating(Set<Map.Entry<String, JsonElement>> root); static Map<String, String> getJsonPathsForTemplating(JsonObject json);  }